diff --git a/README.md b/README.md index 3fb92f2..64eb9a9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Advanced-Sidebox 3.1.14 +## Advanced-Sidebox 3.1.15

Advanced Sidebox Logo diff --git a/Upload/admin/jscripts/asb/asb_scripts.js b/Upload/admin/jscripts/asb/asb_scripts.js index 3e2ad4c..2a62788 100644 --- a/Upload/admin/jscripts/asb/asb_scripts.js +++ b/Upload/admin/jscripts/asb/asb_scripts.js @@ -13,6 +13,9 @@ var ASB = (function(a, $) { hooks: "hooks", actions: "actions", templates: "templates", + error_file_name_empty: "no file name", + error_file_does_not_exist: "file does not exist", + error_file_empty: "file empty or corrupted", }; /** @@ -120,12 +123,30 @@ var ASB = (function(a, $) { * @return void */ function showResults(info) { + var $fileInfo = $("#file_info"), + errorMessage; + // hide all the spinners $("div.ajax_spinners").hide(); - // any response at all means something to show - if (!info) { + // check for errors + if (typeof info.error !== "undefined") { + switch (info.error) { + case 1: + errorMessage = lang.error_file_name_empty; + break; + case 3: + errorMessage = lang.error_file_empty; + break; + default: + errorMessage = lang.error_file_does_not_exist; + break; + } + + $fileInfo.html(errorMessage); return; + } else { + $fileInfo.html("") } /* diff --git a/Upload/admin/jscripts/asb/asb_scripts.min.js b/Upload/admin/jscripts/asb/asb_scripts.min.js index 6ca1430..aaebe54 100644 --- a/Upload/admin/jscripts/asb/asb_scripts.min.js +++ b/Upload/admin/jscripts/asb/asb_scripts.min.js @@ -1 +1 @@ -var ASB=(function(i,f){var g="",b={nothing_found:"nothing found",hooks:"hooks",actions:"actions",templates:"templates"};function j(){new Peeker(f(".replace_all"),f("#replace_content"),/1/,true);new Peeker(f(".replace_all"),f("#header_search"),/0/,true);new Peeker(f(".replace_all"),f("#footer_search"),/0/,true);new Peeker(f(".eval"),f("#template_row"),/0/,true);new Peeker(f(".eval"),f("#header_search"),/0/,true);new Peeker(f(".eval"),f("#footer_search"),/0/,true);new Peeker(f(".eval"),f("#replace_all"),/0/,true);new Peeker(f(".eval"),f("#replace_content"),/0/,true);if(f("#replace_all_yes").prop("checked")){f("#header_search").hide();f("#footer_search").hide()}else{f("#replace_content").hide()}if(f("#eval_yes").prop("checked")){f("#header_search").hide();f("#footer_search").hide();f("#template_row").hide();f("#replace_all").hide();f("#replace_content").hide()}h();f("#filename").blur(e)}function e(a){if(this.value==g||this.value==""){return}g=this.value;f("#hook_list").hide();f("#template_list").hide();f("#action_list").hide();f("div.ajax_spinners").show();f.ajax({type:"post",url:"index.php",data:{module:"config-asb",action:"xmlhttp",mode:"analyze_script",filename:this.value,selected:{hook:f("#hook").val(),template:f("#template_name").val(),action:f("#action").val()}},success:d,error:function(k,m,l){alert("error\n\n"+m+"\n\n"+l)}})}function d(a){f("div.ajax_spinners").hide();if(!a){return}f.each(["hook","template","action"],function(n,l){var o=l+"s",m=''+b.nothing_found.replace("{1}",b[o])+"";if(a[o]){m=a[o]}f("#"+l+"_list").html(m).show()});h()}function h(){if(f("#hook_selector")){f("#hook_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#hook").val(k)})}if(f("#template_selector")){f("#template_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#template_name").val(k)})}if(f("#action_selector")){f("#action_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#action").val(k)})}}function c(a,k){g=a||"";f.extend(b,k||{})}f(j);i.scripts={setup:c};return i})(ASB||{},jQuery); \ No newline at end of file +var ASB=(function(i,f){var g="",b={nothing_found:"nothing found",hooks:"hooks",actions:"actions",templates:"templates",error_file_name_empty:"no file name",error_file_does_not_exist:"file does not exist",error_file_empty:"file empty or corrupted"};function j(){new Peeker(f(".replace_all"),f("#replace_content"),/1/,true);new Peeker(f(".replace_all"),f("#header_search"),/0/,true);new Peeker(f(".replace_all"),f("#footer_search"),/0/,true);new Peeker(f(".eval"),f("#template_row"),/0/,true);new Peeker(f(".eval"),f("#header_search"),/0/,true);new Peeker(f(".eval"),f("#footer_search"),/0/,true);new Peeker(f(".eval"),f("#replace_all"),/0/,true);new Peeker(f(".eval"),f("#replace_content"),/0/,true);if(f("#replace_all_yes").prop("checked")){f("#header_search").hide();f("#footer_search").hide()}else{f("#replace_content").hide()}if(f("#eval_yes").prop("checked")){f("#header_search").hide();f("#footer_search").hide();f("#template_row").hide();f("#replace_all").hide();f("#replace_content").hide()}h();f("#filename").blur(e)}function e(a){if(this.value==g||this.value==""){return}g=this.value;f("#hook_list").hide();f("#template_list").hide();f("#action_list").hide();f("div.ajax_spinners").show();f.ajax({type:"post",url:"index.php",data:{module:"config-asb",action:"xmlhttp",mode:"analyze_script",filename:this.value,selected:{hook:f("#hook").val(),template:f("#template_name").val(),action:f("#action").val()}},success:d,error:function(k,m,l){alert("error\n\n"+m+"\n\n"+l)}})}function d(l){var a=f("#file_info"),k;f("div.ajax_spinners").hide();if(typeof l.error!=="undefined"){switch(l.error){case 1:k=b.error_file_name_empty;break;case 3:k=b.error_file_empty;break;default:k=b.error_file_does_not_exist;break}a.html(k);return}else{a.html("")}f.each(["hook","template","action"],function(o,m){var p=m+"s",n=''+b.nothing_found.replace("{1}",b[p])+"";if(l[p]){n=l[p]}f("#"+m+"_list").html(n).show()});h()}function h(){if(f("#hook_selector")){f("#hook_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#hook").val(k)})}if(f("#template_selector")){f("#template_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#template_name").val(k)})}if(f("#action_selector")){f("#action_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#action").val(k)})}}function c(a,k){g=a||"";f.extend(b,k||{})}f(j);i.scripts={setup:c};return i})(ASB||{},jQuery); \ No newline at end of file diff --git a/Upload/admin/styles/default/asb/global.css b/Upload/admin/styles/default/asb/global.css index 6f64df1..d040cf2 100644 --- a/Upload/admin/styles/default/asb/global.css +++ b/Upload/admin/styles/default/asb/global.css @@ -212,4 +212,10 @@ td.off { .asb_label a:active { color: #333; text-decoration: none; +} + +#file_info { + color: red; + font-weight: bold; + margin-bottom: 5px; } \ No newline at end of file diff --git a/Upload/inc/languages/english/admin/asb.lang.php b/Upload/inc/languages/english/admin/asb.lang.php index 8612ced..2a3884d 100644 --- a/Upload/inc/languages/english/admin/asb.lang.php +++ b/Upload/inc/languages/english/admin/asb.lang.php @@ -365,5 +365,8 @@ $l['asb_ajax_actions'] = 'actions'; $l['asb_ajax_hooks'] = 'hooks'; $l['asb_ajax_templates'] = 'templates'; +$l['asb_ajax_file_name_empty'] = 'no file name'; +$l['asb_ajax_file_does_not_exist'] = 'file does not exist'; +$l['asb_ajax_file_empty'] = 'file empty or corrupted'; ?> diff --git a/Upload/inc/languages/english/admin/asb_addon.lang.php b/Upload/inc/languages/english/admin/asb_addon.lang.php index b6c1fbb..fa4d041 100644 --- a/Upload/inc/languages/english/admin/asb_addon.lang.php +++ b/Upload/inc/languages/english/admin/asb_addon.lang.php @@ -116,7 +116,6 @@ $l['asb_latest_threads_replies'] = 'Replies:'; $l['asb_latest_threads_views'] = 'Views:'; $l['asb_latest_threads_no_threads'] = 'There are no threads to display.'; -$l['asb_latest_threads'] = 'Latest Threads'; $l['asb_gotounread'] = 'Go to first unread post'; // * settings diff --git a/Upload/inc/languages/english/asb_addon.lang.php b/Upload/inc/languages/english/asb_addon.lang.php index b6c1fbb..fa4d041 100644 --- a/Upload/inc/languages/english/asb_addon.lang.php +++ b/Upload/inc/languages/english/asb_addon.lang.php @@ -116,7 +116,6 @@ $l['asb_latest_threads_replies'] = 'Replies:'; $l['asb_latest_threads_views'] = 'Views:'; $l['asb_latest_threads_no_threads'] = 'There are no threads to display.'; -$l['asb_latest_threads'] = 'Latest Threads'; $l['asb_gotounread'] = 'Go to first unread post'; // * settings diff --git a/Upload/inc/plugins/asb.php b/Upload/inc/plugins/asb.php index b889025..b801e91 100644 --- a/Upload/inc/plugins/asb.php +++ b/Upload/inc/plugins/asb.php @@ -14,8 +14,8 @@ // for modules define('IN_ASB', true); -define('ASB_MODULES_DIR', MYBB_ROOT . 'inc/plugins/asb/modules'); -define('ASB_VERSION', '3.1.14'); +define('ASB_MODULES_DIR', MYBB_ROOT.'inc/plugins/asb/modules'); +define('ASB_VERSION', '3.1.15'); define('ASB_CUSTOM_VERSION', '2.0'); define('ASB_SCRIPT_VERSION', '2.0'); @@ -23,22 +23,23 @@ spl_autoload_register('asbClassAutoload'); // some basic functions used everywhere -require_once MYBB_ROOT . 'inc/plugins/asb/functions.php'; +require_once MYBB_ROOT.'inc/plugins/asb/functions.php'; // load the install/admin routines only if in ACP. 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'; } - /** - * class autoloader - * - * @param string the name of the class to load - */ -function asbClassAutoload($className) { - $path = MYBB_ROOT . "inc/plugins/asb/classes/{$className}.php"; +/** + * class autoloader + * + * @param string the name of the class to load + */ +function asbClassAutoload($className) +{ + $path = MYBB_ROOT."inc/plugins/asb/classes/{$className}.php"; if (file_exists($path)) { require_once $path; diff --git a/Upload/inc/plugins/asb/acp.php b/Upload/inc/plugins/asb/acp.php index 32ec453..32472d9 100644 --- a/Upload/inc/plugins/asb/acp.php +++ b/Upload/inc/plugins/asb/acp.php @@ -14,8 +14,8 @@ 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/functions_acp.php'; +require_once MYBB_ROOT.'inc/plugins/asb/install.php'; /** * the ACP page router @@ -33,7 +33,7 @@ function asb_admin() } // now load up, this is our time - global $mybb, $lang, $html, $scripts, $all_scripts, $min; + global $mybb, $lang, $html, $scripts, $allScripts, $min; if (!$lang->asb) { $lang->load('asb'); } @@ -45,21 +45,21 @@ function asb_admin() // URL, link and image markup generator $html = new HTMLGenerator010000(ASB_URL, array('addon', 'pos', 'topic', 'ajax')); - $scripts = asb_get_all_scripts(); + $scripts = asbGetAllScripts(); if (is_array($scripts) && !empty($scripts)) { foreach ($scripts as $filename => $script) { - $all_scripts[$filename] = $script['title']; + $allScripts[$filename] = $script['title']; } } else { - $scripts = $all_scripts = array(); + $scripts = $allScripts = array(); } // if there is an existing function for the action - $page_function = 'asb_admin_' . $mybb->input['action']; - if (function_exists($page_function)) { + $pageFunction = 'asb_admin_'.$mybb->input['action']; + if (function_exists($pageFunction)) { // run it - $page_function(); + $pageFunction(); } else { // default to the main page asb_admin_manage_sideboxes(); @@ -75,9 +75,9 @@ function asb_admin() */ function asb_admin_manage_sideboxes() { - global $mybb, $db, $page, $lang, $html, $scripts, $all_scripts, $min, $cp_style; + global $mybb, $db, $page, $lang, $html, $scripts, $allScripts, $min, $cp_style; - $addons = asb_get_all_modules(); + $addons = asbGetAllModules(); // if there are add-on modules if (is_array($addons)) { @@ -87,56 +87,56 @@ function asb_admin_manage_sideboxes() continue; } - $id = $box_type = $module->get('baseName'); + $id = $type = $module->get('baseName'); $title = $module->get('title'); - $title_url = $html->url(array("action" => 'edit_box', "addon" => $box_type)); - $title_link = $html->link($title_url, $title, array("class" => 'add_box_link', "title" => $lang->asb_add_new_sidebox)); + $titleUrl = $html->url(array('action' => 'edit_box', 'addon' => $type)); + $titleLink = $html->link($titleUrl, $title, array('class' => 'add_box_link', 'title' => $lang->asb_add_new_sidebox)); // add the HTML $modules .= << - {$title_link} + {$titleLink} EOF; } } - $custom = asb_get_all_custom(); + $custom = asbGetAllCustomBoxes(); // if there are custom boxes if (is_array($custom)) { // display them foreach ($custom as $module) { - $id = $box_type = $module->get('baseName'); + $id = $type = $module->get('baseName'); $title = $module->get('title'); - $title_url = $html->url(array("action" => 'edit_box', "addon" => $box_type)); - $title_link = $html->link($title_url, $title, array("class" => 'add_box_link', "title" => $lang->asb_add_new_sidebox)); + $titleUrl = $html->url(array('action' => 'edit_box', 'addon' => $type)); + $titleLink = $html->link($titleUrl, $title, array('class' => 'add_box_link', 'title' => $lang->asb_add_new_sidebox)); // add the HTML - $custom_boxes .= << - {$title_link} + {$titleLink} EOF; } } - $sideboxes = asb_get_all_sideboxes($mybb->input['page']); + $sideboxes = asbGetAllSideBoxes($mybb->input['page']); // if there are side boxes if (is_array($sideboxes)) { // display them foreach ($sideboxes as $sidebox) { // build the side box - $box = asb_build_sidebox_info($sidebox); + $box = asbBuildSideBoxInfo($sidebox); // and sort it by position if ($sidebox->get('position')) { - $right_boxes .= $box; + $rightBoxes .= $box; } else { - $left_boxes .= $box; + $leftBoxes .= $box; } } } @@ -157,17 +157,17 @@ function asb_admin_manage_sideboxes() EOF; $page->output_header("{$lang->asb} - {$lang->asb_manage_sideboxes}"); - asb_output_tabs('asb'); + asbOutputTabs('asb'); - $filter_text = ''; + $filterText = ''; if ($mybb->input['page']) { - $filter_text = $lang->sprintf($lang->asb_filter_label, $all_scripts[$mybb->input['page']]); + $filterText = $lang->sprintf($lang->asb_filter_label, $allScripts[$mybb->input['page']]); } // build the display $markup = <<{$filter_text} +

{$filterText} @@ -183,13 +183,13 @@ function asb_admin_manage_sideboxes() {$modules} @@ -203,7 +203,7 @@ function asb_admin_manage_sideboxes() echo($markup); // output the link menu and MyBB footer - asb_output_footer('manage_sideboxes'); + asbOutputFooter('manage_sideboxes'); } /** @@ -213,7 +213,7 @@ function asb_admin_manage_sideboxes() */ function asb_admin_edit_box() { - global $page, $lang, $mybb, $db, $html, $scripts, $all_scripts, $min, $cp_style; + global $page, $lang, $mybb, $db, $html, $scripts, $allScripts, $min, $cp_style; $ajax = ($mybb->input['ajax'] == 1); @@ -228,20 +228,20 @@ function asb_admin_edit_box() } } - $is_custom = $is_module = false; - $custom_title = 0; + $isCustom = $isModule = false; + $customTitle = 0; $module = $mybb->input['addon']; $parent = new SideboxExternalModule($module); if (!$parent->isValid()) { // did this box come from a custom static box? - $variable_array = explode('_', $module); - $custom_id = $variable_array[count($variable_array) - 1]; + $namePieces = explode('_', $module); + $customId = $namePieces[count($namePieces) - 1]; - $parent = new CustomSidebox($custom_id); + $parent = new CustomSidebox($customId); if ($parent->isValid()) { - $is_custom = true; + $isCustom = true; } else { flash_message($lang->asb_edit_fail_bad_module, 'error'); if (!$ajax) { @@ -250,7 +250,7 @@ function asb_admin_edit_box() die('asb'); } } else { - $is_module = true; + $isModule = true; } // saving? @@ -262,52 +262,52 @@ function asb_admin_edit_box() (int) $mybb->input['display_order'] == 0) { // get a total number of side boxes on the same side and put it at the bottom $query = $db->simple_select('asb_sideboxes', 'display_order', "position='{$position}'"); - $display_order = (int) (($db->num_rows($query) + 1) * 10); + $displayOrder = (int) (($db->num_rows($query) + 1) * 10); } else { /* * or back off if they entered a value * (standard, non-modal interface for * when JS fails or isn't allowed) */ - $display_order = (int) $mybb->input['display_order']; + $displayOrder = (int) $mybb->input['display_order']; } - $sidebox->set('display_order', $display_order); + $sidebox->set('display_order', $displayOrder); // scripts - $script_list = $mybb->input['script_select_box']; - if ($script_list[0] == 'all_scripts' || - (count($script_list) >= count($all_scripts))) { - $script_list = array(); + $scriptArray = $mybb->input['script_select_box']; + if ($scriptArray[0] == 'all_scripts' || + (count($scriptArray) >= count($allScripts))) { + $scriptArray = array(); } - $sidebox->set('scripts', $script_list); + $sidebox->set('scripts', $scriptArray); // groups - $group_list = $mybb->input['group_select_box']; - if ($group_list[0] == 'all') { - $group_list = array(); + $groupArray = $mybb->input['group_select_box']; + if ($groupArray[0] == 'all') { + $groupArray = array(); } - $sidebox->set('groups', $group_list); + $sidebox->set('groups', $groupArray); // themes - $theme_list = $mybb->input['theme_select_box']; - if ($theme_list[0] == 'all_themes') { - $theme_list = array(); + $themeArray = $mybb->input['theme_select_box']; + if ($themeArray[0] == 'all_themes') { + $themeArray = array(); } - $sidebox->set('themes', $theme_list); + $sidebox->set('themes', $themeArray); // box type $sidebox->set('box_type', $module); $sidebox->set('wrap_content', true); - if ($is_module) { + if ($isModule) { $sidebox->set('wrap_content', $parent->get('wrap_content')); - $addon_settings = $parent->get('settings'); + $addonSettings = $parent->get('settings'); - // if the parent module has settings . . . - if (is_array($addon_settings)) { + // if the parent module has settings... + if (is_array($addonSettings)) { // loop through them $settings = array(); - foreach ($addon_settings as $setting) { + foreach ($addonSettings as $setting) { // and if the setting has a value if (isset($mybb->input[$setting['name']])) { // store it @@ -317,12 +317,12 @@ function asb_admin_edit_box() $settings = $parent->doSettingsSave($settings); $sidebox->set('settings', $settings); } - } elseif($is_custom) { + } elseif($isCustom) { // use its wrap_content property $sidebox->set('wrap_content', $parent->get('wrap_content')); } - // if the text field isn't empty . . . + // if the text field isn't empty... if ($mybb->input['box_title']) { // use it $sidebox->set('title', $mybb->input['box_title']); @@ -340,8 +340,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(); + $newId = $sidebox->save(); + asbCacheHasChanged(); // AJAX? if (!$ajax) { @@ -350,31 +350,31 @@ function asb_admin_edit_box() admin_redirect('index.php?module=config-asb'); } - $column_id = 'left_column'; + $columnKey = 'left_column'; if ($position) { - $column_id = 'right_column'; + $columnKey = 'right_column'; } // creating a new box? - $build_script = ''; + $buildScript = ''; if ($id == 0) { // grab the insert id - $id = $new_id; + $id = $newId; // then escape the title - $box_title = addcslashes($sidebox->get('title'), "'"); + $boxTitle = addcslashes($sidebox->get('title'), "'"); /* * create the new
representation of the side box * (title only it will be filled in later by the updater) */ - $build_script = "ASB.sidebox.createDiv({$id}, '{$box_title}', '{$column_id}'); "; + $buildScript = "ASB.sidebox.createDiv({$id}, '{$boxTitle}', '{$columnKey}'); "; } // update the side box after we're done via AJAX $script = << -{$build_script}ASB.sidebox.updateDiv({$id}); +{$buildScript}ASB.sidebox.updateDiv({$id}); EOF; @@ -384,37 +384,37 @@ function asb_admin_edit_box() } if ($id == 0) { - $page_title = $lang->asb_add_a_sidebox; + $pageTitle = $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 - $selected_scripts[] = $mybb->input['page']; + $selectedScripts[] = $mybb->input['page']; } else { // if page isn't set at all then just start out with all scripts - $selected_scripts = 'all_scripts'; + $selectedScripts = 'all_scripts'; } - $custom_title = 0; - $current_title = ''; + $customTitle = 0; + $currentTitle = ''; } else { - $page_title = $lang->asb_edit_a_sidebox; - - // . . . otherwise we are editing so pull the actual info from the side box - $selected_scripts = $sidebox->get('scripts'); - if (empty($selected_scripts)) { - $selected_scripts = 'all_scripts'; - } elseif (isset($selected_scripts[0]) && - strlen($selected_scripts[0]) == 0) { - $script_warning = <<asb_edit_a_sidebox; + + // ...otherwise we are editing so pull the actual info from the side box + $selectedScripts = $sidebox->get('scripts'); + if (empty($selectedScripts)) { + $selectedScripts = 'all_scripts'; + } elseif (isset($selectedScripts[0]) && + strlen($selectedScripts[0]) == 0) { + $scriptWarning = <<{$lang->asb_all_scripts_deactivated}
EOF; } - // check the name of the add-on/custom against the display name of the sidebox, if they differ . . . + // check the name of the add-on/custom against the display name of the sidebox, if they differ... if ($sidebox->get('title') != $parent->get('title')) { // then this box has a custom title - $custom_title = 1; + $customTitle = 1; } } @@ -427,11 +427,11 @@ function asb_admin_edit_box() EOF; - $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'); } else { // standard form stuff $page->add_breadcrumb_item($lang->asb); - $page->add_breadcrumb_item($page_title); + $page->add_breadcrumb_item($pageTitle); // 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'); + $page->output_header("{$lang->asb} - {$pageTitle}"); + $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 + '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, ); // we only need a 'Settings' tab if the current module type has settings - $do_settings = true; + $doSettings = true; if (!$sidebox->hasSettings && !$parent->hasSettings) { unset($tabs['settings']); - $do_settings = false; + $doSettings = false; } reset($tabs); - $observe_onload = false; + $observeOnLoad = false; if (!$ajax) { - $observe_onload = true; + $observeOnLoad = true; } - $page->output_tab_control($tabs, $observe_onload); + $page->output_tab_control($tabs, $observeOnLoad); // custom title? - if ($custom_title == 1) { + if ($customTitle == 1) { // alter the descrption - $current_title = <<{$lang->asb_current_title}

{$sidebox->get('title')}
{$lang->asb_current_title_info} EOF; } else { // default description - $current_title = $lang->asb_default_title_info; + $currentTitle = $lang->asb_default_title_info; } // current editing text - $currently_editing = '"' . $parent->get('title') . '"'; + $currentlyEditing = '"'.$parent->get('title').'"'; - $box_action = $lang->asb_creating; + $boxAction = $lang->asb_creating; if (isset($mybb->input['id'])) { - $box_action = $lang->asb_editing; + $boxAction = $lang->asb_editing; } echo "\n
\n"; - $form_container = new FormContainer('

' . $lang->sprintf($lang->asb_new_sidebox_action, $box_action, $currently_editing) . '

'); + $formContainer = new FormContainer('

'.$lang->sprintf($lang->asb_new_sidebox_action, $boxAction, $currentlyEditing).'

'); if (!$ajax) { // 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')); + $formContainer->output_row($lang->asb_custom_title, $currentTitle, $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')); + $formContainer->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)))); + $formContainer->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)))); // display order - $form_container->output_row($lang->asb_display_order, '', $form->generate_text_box('display_order', $sidebox->get('display_order'))); + $formContainer->output_row($lang->asb_display_order, '', $form->generate_text_box('display_order', $sidebox->get('display_order'))); } else { // box title - $form_container->output_row($lang->asb_title, $current_title, $form->generate_text_box('box_title'), 'box_title', array("id" => 'box_title')); + $formContainer->output_row($lang->asb_title, $currentTitle, $form->generate_text_box('box_title'), 'box_title', array('id' => 'box_title')); // title link and hidden fields - $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')); + $formContainer->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(); + $formContainer->end(); echo "\n
\n
\n"; - $form_container = new FormContainer($lang->asb_which_groups); + $formContainer = new FormContainer($lang->asb_which_groups); // prepare options for which groups $options = array(); @@ -533,22 +533,22 @@ function asb_admin_edit_box() } // which groups - $form_container->output_row('', $script_warning, $form->generate_select_box('group_select_box[]', $options, $groups, array('id' => 'group_select_box', 'multiple' => true, 'size' => 5))); - $form_container->output_row('', '', $form->generate_hidden_field('this_group_count', count($options))); + $formContainer->output_row('', $scriptWarning, $form->generate_select_box('group_select_box[]', $options, $groups, array('id' => 'group_select_box', 'multiple' => true, 'size' => 5))); + $formContainer->output_row('', '', $form->generate_hidden_field('this_group_count', count($options))); - $form_container->end(); + $formContainer->end(); echo "\n
\n
\n"; - $form_container = new FormContainer($lang->asb_which_scripts); + $formContainer = new FormContainer($lang->asb_which_scripts); // prepare for which scripts $choices = array(); $choices['all_scripts'] = $lang->asb_all; // are there active scripts? - if (is_array($all_scripts)) { + if (is_array($allScripts)) { // loop through them - foreach ($all_scripts as $filename => $title) { + foreach ($allScripts as $filename => $title) { // store the script as a choice $choices[$filename] = $title; } @@ -561,7 +561,7 @@ function asb_admin_edit_box() break; case 2: unset($choices['all_scripts']); - $selected_scripts = array_flip($choices); + $selectedScripts = array_flip($choices); break; case 1: $choices['all_scripts'] = $lang->asb_all_scripts_disabled; @@ -569,11 +569,11 @@ function asb_admin_edit_box() } // which scripts - $form_container->output_row('', $script_warning, $form->generate_select_box('script_select_box[]', $choices, $selected_scripts, array("id" => 'script_select_box', "multiple" => true, 'size' => 5))); - $form_container->end(); + $formContainer->output_row('', $scriptWarning, $form->generate_select_box('script_select_box[]', $choices, $selectedScripts, array('id' => 'script_select_box', 'multiple' => true, 'size' => 5))); + $formContainer->end(); echo "\n
\n
\n"; - $form_container = new FormContainer($lang->asb_which_themes); + $formContainer = new FormContainer($lang->asb_which_themes); // do we have themes stored? $themes = $sidebox->get('themes'); @@ -581,16 +581,16 @@ function asb_admin_edit_box() $themes = 'all_themes'; } - $choices = array("all_themes" => 'All Themes') + asb_get_all_themes(); + $choices = array('all_themes' => 'All Themes') + asbGetAllThemes(); // which scripts - $form_container->output_row('', '', $form->generate_select_box('theme_select_box[]', $choices, $themes, array("id" => 'theme_select_box', "multiple" => true, 'size' => 5))); - $form_container->end(); + $formContainer->output_row('', '', $form->generate_select_box('theme_select_box[]', $choices, $themes, array('id' => 'theme_select_box', 'multiple' => true, 'size' => 5))); + $formContainer->end(); - if ($do_settings) { + if ($doSettings) { echo "
\n
\n"; - $form_container = new FormContainer($lang->asb_modal_tab_settings_desc); + $formContainer = new FormContainer($lang->asb_modal_tab_settings_desc); $settings = $parent->get('settings'); @@ -605,10 +605,10 @@ function asb_admin_edit_box() foreach ((array) $settings as $setting) { // allow the handler to build module settings - asb_build_setting($form, $form_container, $setting); + asbBuildSetting($form, $formContainer, $setting); } - $form_container->end(); + $formContainer->end(); $parent->doSettingsLoad(); } @@ -630,7 +630,7 @@ function asb_admin_edit_box() $form->end(); // output the link menu and MyBB footer - asb_output_footer('edit_box'); + asbOutputFooter('edit_box'); } } @@ -646,16 +646,16 @@ function asb_admin_custom_boxes() if ($mybb->input['mode'] == 'export') { if ((int) $mybb->input['id'] == 0) { flash_message($lang->asb_custom_export_error, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } - $this_custom = new CustomSidebox($mybb->input['id']); - if (!$this_custom->isValid()) { + $custom = new CustomSidebox($mybb->input['id']); + if (!$custom->isValid()) { flash_message($lang->asb_custom_export_error, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } - $this_custom->export(array("version" => ASB_CUSTOM_VERSION)); + $custom->export(array('version' => ASB_CUSTOM_VERSION)); exit(); } @@ -663,22 +663,22 @@ function asb_admin_custom_boxes() // info good? if ((int) $mybb->input['id'] == 0) { flash_message($lang->asb_add_custom_box_delete_failure, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } // nuke it - $this_custom = new CustomSidebox($mybb->input['id']); + $custom = new CustomSidebox($mybb->input['id']); // success? - if (!$this_custom->remove()) { + if (!$custom->remove()) { flash_message($lang->asb_add_custom_box_delete_failure, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } // :) flash_message($lang->asb_add_custom_box_delete_success, 'success'); - asb_cache_has_changed(); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + asbCacheHasChanged(); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } // POSTing? @@ -687,17 +687,17 @@ function asb_admin_custom_boxes() if (!$_FILES['file'] || $_FILES['file']['error'] == 4) { flash_message($lang->asb_custom_import_no_file, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } if ($_FILES['file']['error']) { flash_message($lang->sprintf($lang->asb_custom_import_file_error, $_FILES['file']['error']), 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } if (!is_uploaded_file($_FILES['file']['tmp_name'])) { flash_message($lang->asb_custom_import_file_upload_error, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } $contents = @file_get_contents($_FILES['file']['tmp_name']); @@ -705,17 +705,17 @@ function asb_admin_custom_boxes() if (!trim($contents)) { flash_message($lang->asb_custom_import_file_empty, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } - require_once MYBB_ROOT . 'inc/class_xml.php'; + require_once MYBB_ROOT.'inc/class_xml.php'; $parser = new XMLParser($contents); $tree = $parser->get_tree(); if (!is_array($tree) || empty($tree)) { flash_message($lang->asb_custom_import_file_empty, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } if (!is_array($tree['asb_custom_sideboxes']) || @@ -723,55 +723,66 @@ function asb_admin_custom_boxes() if (!is_array($tree['adv_sidebox']) || !is_array($tree['adv_sidebox']['custom_sidebox'])) { flash_message($lang->asb_custom_import_file_empty, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } - $results = asb_legacy_custom_import($tree); + $results = asbLegacyCustomImport($tree); if (!is_array($results)) { flash_message($results, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } $custom = new CustomSidebox($results); } else { $custom = new CustomSidebox; if (!$custom->import($contents)) { flash_message($lang->asb_custom_import_fail_generic, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } } if (!$custom->save()) { flash_message($lang->asb_custom_box_save_failure, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url(array('action' => 'custom_boxes'))); } flash_message($lang->asb_custom_import_save_success, 'success'); - admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $custom->get('id')))); + admin_redirect($html->url(array('action' => 'custom_boxes', 'id' => $custom->get('id')))); } else { // saving? if ($mybb->input['save_box_submit'] == 'Save') { + $id = (int) $mybb->input['id']; + if (!$mybb->input['box_name'] || !$mybb->input['box_content']) { + $redirectArray = array( + 'action' => 'custom_boxes', + 'mode' => 'edit', + ); + + if ($id) { + $redirectArray['id'] = $id; + } + flash_message($lang->asb_custom_box_save_failure_no_content, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes'))); + admin_redirect($html->url($redirectArray)); } - $this_custom = new CustomSidebox((int) $mybb->input['id']); + $custom = new CustomSidebox($id); // get the info - $this_custom->set('title', $mybb->input['box_name']); - $this_custom->set('description', $mybb->input['box_description']); - $this_custom->set('content', $mybb->input['box_content']); - $this_custom->set('wrap_content', ($mybb->input['wrap_content'] == 'yes')); + $custom->set('title', $mybb->input['box_name']); + $custom->set('description', $mybb->input['box_description']); + $custom->set('content', $mybb->input['box_content']); + $custom->set('wrap_content', ($mybb->input['wrap_content'] == 'yes')); // success? - if (!$this_custom->save()) { + if (!$custom->save()) { flash_message($lang->asb_custom_box_save_failure, 'error'); - admin_redirect($html->url(array("action" => 'custom_boxes', "id" => $this_custom->get('id')))); + admin_redirect($html->url(array('action' => 'custom_boxes', 'id' => $custom->get('id')))); } 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')))); + asbCacheHasChanged(); + admin_redirect($html->url(array('action' => 'custom_boxes', 'id' => $custom->get('id')))); } } } @@ -779,10 +790,10 @@ function asb_admin_custom_boxes() $page->add_breadcrumb_item($lang->asb, $html->url()); if ($mybb->input['mode'] == 'edit') { - $queryadmin = $db->simple_select('adminoptions', '*', "uid='{$mybb->user['uid']}'"); - $admin_options = $db->fetch_array($queryadmin); + $query = $db->simple_select('adminoptions', '*', "uid='{$mybb->user['uid']}'"); + $adminOptions = $db->fetch_array($query); - if ($admin_options['codepress'] != 0) { + if ($adminOptions['codepress'] != 0) { $page->extra_header .= << @@ -802,17 +813,17 @@ function asb_admin_custom_boxes() EOF; } - $this_box = new CustomSidebox((int) $mybb->input['id']); + $custom = new CustomSidebox((int) $mybb->input['id']); $action = $lang->asb_add_custom; - if ($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'); + if ($custom->get('id')) { + $specifyBox = '&id='.$custom->get('id'); + $currentlyEditing = $lang->asb_editing.': '.$custom->get('title').''; + $action = $lang->asb_edit.' '.$custom->get('title'); } else { // new box - $specify_box = ''; - $sample_content = <<
@@ -823,52 +834,54 @@ function asb_admin_custom_boxes() EOF; - $this_box->set('content', $sample_content); - $this_box->set('wrap_content', true); + $custom->set('content', $sampleContent); + $custom->set('wrap_content', true); } $page->extra_header .= << EOF; - $page->add_breadcrumb_item($lang->asb_custom_boxes, $html->url(array("action" => 'custom_boxes'))); + $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} - {$action}"); - asb_output_tabs('asb_add_custom'); + asbOutputTabs('asb_add_custom'); - $form = new Form($html->url(array("action" => 'custom_boxes')) . $specify_box, 'post', 'edit_box'); - $form_container = new FormContainer($currently_editing); + $onClick = <<asb_custom_box_save_failure_no_content}', { theme: 'error' }); return false; } +EOF; + + $form = new Form($html->url(array('action' => 'custom_boxes')).$specifyBox, 'post', 'edit_box'); + $formContainer = new FormContainer($currentlyEditing); - $form_container->output_cell($lang->asb_name); - $form_container->output_cell($lang->asb_description); - $form_container->output_cell($lang->asb_custom_box_wrap_content); - $form_container->output_row(''); + $formContainer->output_row_header($lang->asb_name); + $formContainer->output_row_header($lang->asb_description); + $formContainer->output_row_header($lang->asb_custom_box_wrap_content); // name - $form_container->output_cell($form->generate_text_box('box_name', $this_box->get('title'), array("id" => 'box_name'))); + $formContainer->output_cell($form->generate_text_box('box_name', $custom->get('title'), array('id' => 'box_name'))); // description - $form_container->output_cell($form->generate_text_box('box_description', $this_box->get('description'))); + $formContainer->output_cell($form->generate_text_box('box_description', $custom->get('description'))); // wrap content? - $form_container->output_cell($form->generate_check_box('wrap_content', 'yes', $lang->asb_custom_box_wrap_content_desc, array("checked" => $this_box->get('wrap_content')))); - $form_container->output_row(''); + $formContainer->output_cell($form->generate_check_box('wrap_content', 'yes', $lang->asb_custom_box_wrap_content_desc, array('checked' => $custom->get('wrap_content')))); + $formContainer->construct_row(); - $form_container->output_cell('Content:', array("colspan" => 3)); - $form_container->output_row(''); + $formContainer->output_cell('Content:', array('colspan' => 3)); + $formContainer->construct_row(); // content - $form_container->output_cell($form->generate_text_area('box_content', $this_box->get('content'), array("id" => 'box_content', 'class' => '', 'style' => 'width: 100%; height: 500px;')), array("colspan" => 3)); - $form_container->output_row(''); + $formContainer->output_cell($form->generate_text_area('box_content', $custom->get('content'), array('id' => 'box_content', 'class' => '', 'style' => 'width: 100%; height: 500px;')), array('colspan' => 3)); + $formContainer->construct_row(); // finish form - $form_container->end(); - $buttons[] = $form->generate_submit_button('Save', array('name' => 'save_box_submit')); + $formContainer->end(); + $buttons[] = $form->generate_submit_button('Save', array('name' => 'save_box_submit', 'onclick' => $onClick)); $form->output_submit_wrapper($buttons); $form->end(); - if($admin_options['codepress'] != 0) - { + if ($adminOptions['codepress'] != 0) { echo << var editor = CodeMirror.fromTextArea(document.getElementById("box_content"), { @@ -880,14 +893,14 @@ function asb_admin_custom_boxes() indentWithTabs: true, indentUnit: 4, mode: "text/html", - theme: "mybb" + theme: "mybb", }); EOF; - - // build link bar and ACP footer - asb_output_footer('edit_custom'); } + + // build link bar and ACP footer + asbOutputFooter('edit_custom'); } $page->extra_header .= <<add_breadcrumb_item($lang->asb_custom_boxes); $page->output_header("{$lang->asb} - {$lang->asb_custom_boxes}"); - asb_output_tabs('asb_custom'); + asbOutputTabs('asb_custom'); - $new_box_url = $html->url(array("action" => 'custom_boxes', "mode" => 'edit')); - $new_box_link = $html->link($new_box_url, $lang->asb_add_custom_box_types, array("style" => 'font-weight: bold;', "title" => $lang->asb_add_custom_box_types, "icon" => "styles/{$cp_style}/images/asb/add.png"), array("alt" => '+', "style" => 'margin-bottom: -3px;', "title" => $lang->asb_add_custom_box_types)); - echo($new_box_link . '

'); + $newBoxUrl = $html->url(array('action' => 'custom_boxes', 'mode' => 'edit')); + $newBoxLink = $html->link($newBoxUrl, $lang->asb_add_custom_box_types, array('style' => 'font-weight: bold;', 'title' => $lang->asb_add_custom_box_types, 'icon' => "styles/{$cp_style}/images/asb/add.png"), array('alt' => '+', 'style' => 'margin-bottom: -3px;', 'title' => $lang->asb_add_custom_box_types)); + echo($newBoxLink.'

'); $table = new Table; $table->construct_header($lang->asb_name); $table->construct_header($lang->asb_custom_box_desc); - $table->construct_header($lang->asb_controls, array("colspan" => 2)); + $table->construct_header($lang->asb_controls, array('colspan' => 2)); - $custom = asb_get_all_custom(); + $customBoxes = asbGetAllCustomBoxes(); - // if there are saved types . . . - if (is_array($custom) && - !empty($custom)) { + // if there are saved types... + if (is_array($customBoxes) && + !empty($customBoxes)) { // display them - foreach ($custom as $this_custom) { - $data = $this_custom->get('data'); + foreach ($customBoxes as $custom) { + $data = $custom->get('data'); // name (edit link) - $edit_url = $html->url(array("action" => 'custom_boxes', "mode" => 'edit', "id" => $data['id'])); - $edit_link = $html->link($edit_url, $data['title'], array("title" => $lang->asb_edit, "style" => 'font-weight: bold;')); + $editUrl = $html->url(array('action' => 'custom_boxes', 'mode' => 'edit', 'id' => $data['id'])); + $editLink = $html->link($editUrl, $data['title'], array('title' => $lang->asb_edit, 'style' => 'font-weight: bold;')); - $table->construct_cell($edit_link, array("width" => '30%')); + $table->construct_cell($editLink, array('width' => '30%')); // description if ($data['description']) { @@ -927,45 +940,45 @@ function asb_admin_custom_boxes() } else { $description = "{$lang->asb_no_description}"; } - $table->construct_cell($description, array("width" => '60%')); + $table->construct_cell($description, array('width' => '60%')); // options popup - $popup = new PopupMenu('box_' . $data['id'], $lang->asb_options); + $popup = new PopupMenu('box_'.$data['id'], $lang->asb_options); // edit - $popup->add_item($lang->asb_edit, $edit_url); + $popup->add_item($lang->asb_edit, $editUrl); // delete - $popup->add_item($lang->asb_delete, $html->url(array("action" => 'custom_boxes', "mode" => 'delete', "id" => $data['id'])), "return confirm('{$lang->asb_custom_del_warning}');"); + $popup->add_item($lang->asb_delete, $html->url(array('action' => 'custom_boxes', 'mode' => 'delete', 'id' => $data['id'])), "return confirm('{$lang->asb_custom_del_warning}');"); // export - $popup->add_item($lang->asb_custom_export, $html->url(array("action" => 'custom_boxes', "mode" => 'export', "id" => $data['id']))); + $popup->add_item($lang->asb_custom_export, $html->url(array('action' => 'custom_boxes', 'mode' => 'export', 'id' => $data['id']))); // popup cell - $table->construct_cell($popup->fetch(), array("width" => '10%')); + $table->construct_cell($popup->fetch(), array('width' => '10%')); // finish the table $table->construct_row(); } } else { // no saved types - $table->construct_cell($lang->asb_no_custom_boxes, array("colspan" => 4)); + $table->construct_cell($lang->asb_no_custom_boxes, array('colspan' => 4)); $table->construct_row(); } $table->output($lang->asb_custom_box_types); echo('

'); - $import_form = new Form($html->url(array("action" => 'custom_boxes', "mode" => 'import')), 'post', '', 1); - $import_form_container = new FormContainer($lang->asb_custom_import); - $import_form_container->output_row($lang->asb_custom_import_select_file, '', $import_form->generate_file_upload_box('file')); - $import_form_container->end(); - $import_buttons[] = $import_form->generate_submit_button($lang->asb_custom_import, array('name' => 'import')); - $import_form->output_submit_wrapper($import_buttons); - $import_form->end(); + $importForm = new Form($html->url(array('action' => 'custom_boxes', 'mode' => 'import')), 'post', '', 1); + $importFormContainer = new FormContainer($lang->asb_custom_import); + $importFormContainer->output_row($lang->asb_custom_import_select_file, '', $importForm->generate_file_upload_box('file')); + $importFormContainer->end(); + $importButtons[] = $importForm->generate_submit_button($lang->asb_custom_import, array('name' => 'import')); + $importForm->output_submit_wrapper($importButtons); + $importForm->end(); // build link bar and ACP footer - asb_output_footer('custom'); + asbOutputFooter('custom'); } /** @@ -982,30 +995,30 @@ function asb_admin_manage_scripts() if ($mybb->request_method == 'post') { if ($mybb->input['mode'] == 'edit') { $mybb->input['action'] = $mybb->input['script_action']; - $script_info = new ScriptInfo($mybb->input); + $script = new ScriptInfo($mybb->input); - if (!$script_info->save()) { + if (!$script->save()) { flash_message($lang->asb_script_save_fail, 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } flash_message($lang->asb_script_save_success, 'success'); - asb_cache_has_changed(); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + asbCacheHasChanged(); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } elseif ($mybb->input['mode'] == 'import') { if (!$_FILES['file'] || $_FILES['file']['error'] == 4) { flash_message($lang->asb_custom_import_no_file, 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } if ($_FILES['file']['error']) { flash_message($lang->sprintf($lang->asb_custom_import_file_error, $_FILES['file']['error']), 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } if (!is_uploaded_file($_FILES['file']['tmp_name'])) { flash_message($lang->asb_custom_import_file_upload_error, 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } $contents = @file_get_contents($_FILES['file']['tmp_name']); @@ -1013,24 +1026,24 @@ function asb_admin_manage_scripts() if (strlen(trim($contents)) == 0) { flash_message($lang->asb_custom_import_file_empty, 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } - $this_script = new ScriptInfo; - if (!$this_script->import($contents)) { + $script = new ScriptInfo; + if (!$script->import($contents)) { flash_message($lang->asb_script_import_fail, 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } - if (!$this_script->save()) { + if (!$script->save()) { flash_message($lang->asb_script_import_fail, 'error'); } flash_message($lang->asb_script_import_success, 'success'); - asb_cache_has_changed(); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + asbCacheHasChanged(); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } elseif ($mybb->input['mode'] == 'inline') { - $redirect = $html->url(array("action" => 'manage_scripts')); + $redirect = $html->url(array('action' => 'manage_scripts')); if (!is_array($mybb->input['asb_inline_ids']) || empty($mybb->input['asb_inline_ids'])) { @@ -1096,7 +1109,7 @@ function asb_admin_manage_scripts() $objectTitle = $lang->asb_script_definitions; if ($job_count > 0) { $status = 'success'; - asb_cache_has_changed(); + asbCacheHasChanged(); if ($job_count == 1) { $objectTitle = $lang->asb_script_definition; } @@ -1108,75 +1121,75 @@ function asb_admin_manage_scripts() if ($mybb->input['mode'] == 'delete' && $mybb->input['id']) { - $this_script = new ScriptInfo((int) $mybb->input['id']); - if (!$this_script->remove()) { + $script = new ScriptInfo((int) $mybb->input['id']); + if (!$script->remove()) { flash_message($lang->asb_script_delete_fail, 'error'); } else { flash_message($lang->asb_script_delete_success, 'success'); - asb_cache_has_changed(); + asbCacheHasChanged(); } } elseif ($mybb->input['mode'] == 'export' && $mybb->input['id']) { - $this_script = new ScriptInfo((int) $mybb->input['id']); + $script = new ScriptInfo((int) $mybb->input['id']); - if (!$this_script->export(array("version" => ASB_SCRIPT_VERSION))) { + if (!$script->export(array('version' => ASB_SCRIPT_VERSION))) { flash_message($lang->asb_script_export_fail, 'error'); - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } exit; } elseif (($mybb->input['mode'] == 'activate' || $mybb->input['mode'] == 'deactivate') && $mybb->input['id']) { - $this_script = new ScriptInfo((int) $mybb->input['id']); - $this_script->set('active', ($mybb->input['mode'] == 'activate')); + $script = new ScriptInfo((int) $mybb->input['id']); + $script->set('active', ($mybb->input['mode'] == 'activate')); - if (!$this_script->save()) { + if (!$script->save()) { $action = ($mybb->input['mode'] == 'activate') ? $lang->asb_script_activate_fail : $lang->asb_script_deactivate_fail; flash_message($action, 'error'); } else { $action = ($mybb->input['mode'] == 'activate') ? $lang->asb_script_activate_success : $lang->asb_script_deactivate_success; flash_message($action, 'success'); - asb_cache_has_changed(); + asbCacheHasChanged(); } - admin_redirect($html->url(array("action" => 'manage_scripts'))); + admin_redirect($html->url(array('action' => 'manage_scripts'))); } $data = array( - "active" => 'false', - "find_top" => '{$header}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "width_left" => 160, - "width_right" => 160 + 'active' => 'false', + 'find_top' => '{$header}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'width_left' => 160, + 'width_right' => 160, ); if ($mybb->input['mode'] == 'edit') { - $this_script = new ScriptInfo((int) $mybb->input['id']); + $script = new ScriptInfo((int) $mybb->input['id']); - $detected_show = ' style="display: none;"'; - $button_text = $lang->asb_add; + $detectedShow = ' style="display: none;"'; + $buttonText = $lang->asb_add; $filename = ''; $action = $lang->asb_edit_script; - if ($this_script->isValid()) { - $data = $this_script->get('data'); + if ($script->isValid()) { + $data = $script->get('data'); - $detected_info = asb_detect_script_info($data['filename'], array( - "hook" => $data['hook'], - "action" => $data['action'], - "template" => $data['template_name'], + $detectedInfo = asbDetectScriptInfo($data['filename'], array( + 'hook' => $data['hook'], + 'action' => $data['action'], + 'template' => $data['template_name'], )); - $detected_show = ''; - $button_text = $lang->asb_update; + $detectedShow = ''; + $buttonText = $lang->asb_update; $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); + $query = $db->simple_select('adminoptions', '*', "uid='{$mybb->user['uid']}'"); + $adminOptions = $db->fetch_array($query); - if ($admin_options['codepress'] != 0) { + if ($adminOptions['codepress'] != 0) { $page->extra_header .= << @@ -1206,6 +1219,9 @@ function asb_admin_manage_scripts() hooks: '{$lang->asb_ajax_hooks}', actions: '{$lang->asb_ajax_actions}', templates: '{$lang->asb_ajax_templates}', + error_file_name_empty: '{$lang->asb_ajax_file_name_empty}', + error_file_does_not_exist: '{$lang->asb_ajax_file_does_not_exist}', + error_file_empty: '{$lang->asb_ajax_file_empty}', }); // --> @@ -1213,49 +1229,50 @@ function asb_admin_manage_scripts() EOF; - $page->add_breadcrumb_item($lang->asb_manage_scripts, $html->url(array("action" => 'manage_scripts'))); + $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} - {$lang->asb_edit_script}"); - asb_output_tabs('asb_edit_script'); + asbOutputTabs('asb_edit_script'); $spinner = <<
- - -"; } else { - $scripts = $all_scripts; + $scripts = $allScripts; } } elseif (isset($scripts[0]) && strlen($scripts[0]) == 0) { @@ -245,11 +245,11 @@ function asb_build_visibility_rows($sidebox, &$group_count, &$global) } $script_rows = ''; - foreach ($all_scripts as $script => $script_title) { + foreach ($allScripts as $script => $script_title) { $script_title_full = ''; if (strlen($script_title) > 15) { $script_title_full = $script_title; - $script_title = substr($script_title, 0, 15) . '...'; + $script_title = substr($script_title, 0, 15).'...'; } $script_rows .= <<get('themes'); if (!$themes) { @@ -328,20 +328,20 @@ function asb_build_theme_visibility_list($sidebox, $colspan, $global) if (!$good_themes || count($good_themes) == count($themes)) { - $theme_list = $lang->asb_visibile_for_all_themes; + $themeList = $lang->asb_visibile_for_all_themes; if ($global) { return ''; } } else { - $theme_list = ''; + $themeList = ''; foreach ($themes as $tid => $name) { if ($good_themes && !in_array($tid, $good_themes)) { - $theme_list .= <<{$name} EOF; } else { - $theme_list .= << - + EOF; } @@ -363,7 +363,7 @@ function asb_build_theme_visibility_list($sidebox, $colspan, $global) * @param bool produce delete link? * @return string html */ -function asb_build_sidebox_info($sidebox, $wrap = true, $ajax = false) +function asbBuildSideBoxInfo($sidebox, $wrap=true, $ajax=false) { // must be a valid object if ($sidebox instanceof SideboxObject == false || @@ -371,7 +371,7 @@ function asb_build_sidebox_info($sidebox, $wrap = true, $ajax = false) return false; } - global $html, $scripts, $all_scripts, $lang, $cp_style; + global $html, $scripts, $allScripts, $lang, $cp_style; $title = $sidebox->get('title'); $id = $sidebox->get('id'); @@ -379,25 +379,25 @@ function asb_build_sidebox_info($sidebox, $wrap = true, $ajax = false) $module = $sidebox->get('box_type'); // visibility table - $visibility = '' . asb_build_permissions_table($sidebox) . ''; + $visibility = ''.asbBuildPermissionsTable($sidebox).''; // edit link - $edit_link = $html->url(array("action" => 'edit_box', "id" => $id, "addon" => $module, "pos" => $pos)); - $edit_icon = <<{$lang->asb_edit} + $editUrl = $html->url(array('action' => 'edit_box', 'id' => $id, 'addon' => $module, 'pos' => $pos)); + $editIcon = <<{$lang->asb_edit} EOF; // delete link (only used if JS is disabled) if (!$ajax) { - $delete_link = $html->url(array("action" => 'delete_box', "id" => $id)); - $delete_icon = <<{$lang->asb_delete} + $deleteUrl = $html->url(array('action' => 'delete_box', 'id' => $id)); + $deleteIcon = <<{$lang->asb_delete} EOF; } // the content $box = <<Information{$visibility}{$edit_icon}{$delete_icon}{$title} +Information{$visibility}{$editIcon}{$deleteIcon}{$title} EOF; // the
(if applicable) @@ -417,7 +417,7 @@ function asb_build_sidebox_info($sidebox, $wrap = true, $ajax = false) * * @return void */ -function asb_cache_has_changed() +function asbCacheHasChanged() { AdvancedSideboxCache::getInstance()->update('has_changed', true); } @@ -430,84 +430,90 @@ function asb_cache_has_changed() * @param array * @return array script component information */ -function asb_detect_script_info($filename, $selected = array()) +function asbDetectScriptInfo($filename, $selected=array()) { global $lang; // check all the info if (strlen(trim($filename)) == 0) { - return false; + return array( + 'error' => 1, + ); } - $full_path = '../' . trim($filename); - if (!file_exists($full_path)) { - return false; + $fullPath = '../'.trim($filename); + if (!file_exists($fullPath)) { + return array( + 'error' => 2, + ); } - $contents = @file_get_contents($full_path); + $contents = @file_get_contents($fullPath); if (!$contents) { - return false; + return array( + 'error' => 3, + ); } // build the object info $info = array( - "hook" => array( - "pattern" => "#\\\$plugins->run_hooks\([\"|'|"]([\w|_]*)[\"|'|"](.*?)\)#i", - "filter" => '_do_', - "plural" => $lang->asb_hooks + 'hook' => array( + 'pattern' => "#\\\$plugins->run_hooks\([\"|'|"]([\w|_]*)[\"|'|"](.*?)\)#i", + 'filter' => '_do_', + 'plural' => $lang->asb_hooks, + ), + 'template' => array( + 'pattern' => "#\\\$templates->get\([\"|'|"]([\w|_]*)[\"|'|"](.*?)\)#i", + 'filter' => '', + 'plural' => $lang->asb_templates, ), - "template" => array( - "pattern" => "#\\\$templates->get\([\"|'|"]([\w|_]*)[\"|'|"](.*?)\)#i", - "filter" => '', - "plural" => $lang->asb_templates + 'action' => array( + 'pattern' => "#\\\$mybb->input\[[\"|'|"]action[\"|'|"]\] == [\"|'|"]([\w|_]*)[\"|'|"]#i", + 'filter' => '', + 'plural' => $lang->asb_actions, ), - "action" => array( - "pattern" => "#\\\$mybb->input\[[\"|'|"]action[\"|'|"]\] == [\"|'|"]([\w|_]*)[\"|'|"]#i", - "filter" => '', - "plural" => $lang->asb_actions - ) ); $form = new Form('', '', '', 0, '', true); foreach (array('hook', 'template', 'action') as $key) { - $array_name = "{$key}s"; - $$array_name = array(); + $element = "{$key}s"; + $$element = array(); // find any references to the current object preg_match_all($info[$key]['pattern'], $contents, $matches, PREG_SET_ORDER); foreach ($matches as $match) { // no duplicates and if there is a filter check it - if (!in_array($match[1], $$array_name) && - (strlen(${$array_name}['filter'] == 0 || - strpos($match[1], ${$array_name}['filter']) === false))) { - ${$array_name}[$match[1]] = $match[1]; + if (!in_array($match[1], $$element) && + (strlen(${$element}['filter'] == 0 || + strpos($match[1], ${$element}['filter']) === false))) { + ${$element}[$match[1]] = $match[1]; } } // anything to show? - if (!empty($$array_name)) { + if (!empty($$element)) { // sort the results, preserving keys - ksort($$array_name); + ksort($$element); // make none = '' the first entry - $$array_name = array_reverse($$array_name); - ${$array_name}[] = 'none'; - $$array_name = array_reverse($$array_name); + $$element = array_reverse($$element); + ${$element}[] = 'none'; + $$element = array_reverse($$element); // store the HTML select box - $return_array[$array_name] = '' . $lang->asb_detected . ' ' . $info[$key]['plural'] . ':
' . $form->generate_select_box("{$array_name}_options", $$array_name, $selected[$key], array("id" => "{$key}_selector")) . '

'; + $returnArray[$element] = ''.$lang->asb_detected.' '.$info[$key]['plural'].':
'.$form->generate_select_box("{$element}_options", $$element, $selected[$key], array('id' => "{$key}_selector")).'

'; } else { - $varName = "asb_ajax_{$array_name}"; + $varName = "asb_ajax_{$element}"; $noContent = $lang->sprintf($lang->asb_ajax_nothing_found, $lang->$varName); // store the no content message - $return_array[$array_name] = <<{$noContent} EOF; } } - return $return_array; + return $returnArray; } /** @@ -516,7 +522,7 @@ function asb_detect_script_info($filename, $selected = array()) * @param array * @return void */ -function asb_legacy_custom_import($tree) +function asbLegacyCustomImport($tree) { global $lang; @@ -530,19 +536,19 @@ function asb_legacy_custom_import($tree) $property == 'value') { continue; } - $input_array[$property] = $value['value']; + $inputArray[$property] = $value['value']; } - if ($input_array['content'] && - $input_array['checksum'] && - my_strtolower(md5(base64_decode($input_array['content']))) == my_strtolower($input_array['checksum'])) { - $input_array['content'] = trim(base64_decode($input_array['content'])); - $input_array['title'] = $input_array['name']; - return $input_array; + if ($inputArray['content'] && + $inputArray['checksum'] && + my_strtolower(md5(base64_decode($inputArray['content']))) == my_strtolower($inputArray['checksum'])) { + $inputArray['content'] = trim(base64_decode($inputArray['content'])); + $inputArray['title'] = $inputArray['name']; + return $inputArray; } $error = $lang->asb_custom_import_file_empty; - if ($input_array['content']) { + if ($inputArray['content']) { $error = $lang->asb_custom_import_file_corrupted; } return $error; @@ -554,18 +560,18 @@ function asb_legacy_custom_import($tree) * @param string script to show or 'all_scripts' to avoid filtering altogether * @return string html */ -function asb_build_filter_selector($filter) +function asbBuildFilterSelector($filter) { - global $all_scripts; + global $allScripts; - // if there are active scripts . . . - if (!is_array($all_scripts) || - empty($all_scripts)) { + // if there are active scripts... + if (!is_array($allScripts) || + empty($allScripts)) { return; } global $lang, $html; - $options = array_merge(array("" => 'no filter'), $all_scripts); + $options = array_merge(array('' => 'no filter'), $allScripts); $form = new Form($html->url(), 'post', 'script_filter', 0, 'script_filter'); echo($form->generate_select_box('page', $options, $filter)); echo($form->generate_submit_button('Filter', array('name' => 'filter'))); @@ -580,73 +586,73 @@ function asb_build_filter_selector($filter) * @param array setting properties * @return void */ -function asb_build_setting($this_form, $this_form_container, $setting) +function asbBuildSetting($this_form, $this_form_container, $setting) { // create each element with unique id and name properties $options = ''; $type = explode("\n", $setting['optionscode']); $type = array_map('trim', $type); - $element_name = "{$setting['name']}"; - $element_id = "setting_{$setting['name']}"; - $row_id = "row_{$element_id}"; + $elementName = "{$setting['name']}"; + $elementId = "setting_{$setting['name']}"; + $rowId = "row_{$elementId}"; // prepare labels - $this_label = '' . htmlspecialchars_uni($setting['title']) . ''; - $this_desc = '' . $setting['description'] . ''; + $thisLabel = ''.htmlspecialchars_uni($setting['title']).''; + $thisDescription = ''.$setting['description'].''; // sort by type if ($type[0] == 'text' || $type[0] == '') { - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_text_box($element_name, $setting['value'], array('id' => $element_id)), $element_name, array("id" => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_text_box($elementName, $setting['value'], array('id' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'textarea') { - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_text_area($element_name, $setting['value'], array('id' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_text_area($elementName, $setting['value'], array('id' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'yesno') { - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_yes_no_radio($element_name, $setting['value'], true, array('id' => $element_id.'_yes', 'class' => $element_id), array('id' => $element_id.'_no', 'class' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_yes_no_radio($elementName, $setting['value'], true, array('id' => $elementId.'_yes', 'class' => $elementId), array('id' => $elementId.'_no', 'class' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'onoff') { - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_on_off_radio($element_name, $setting['value'], true, array('id' => $element_id.'_on', 'class' => $element_id), array('id' => $element_id.'_off', 'class' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_on_off_radio($elementName, $setting['value'], true, array('id' => $elementId.'_on', 'class' => $elementId), array('id' => $elementId.'_off', 'class' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'language') { $languages = $lang->get_languages(); - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_select_box($elementName, $languages, $setting['value'], array('id' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'adminlanguage') { $languages = $lang->get_languages(1); - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_select_box($element_name, $languages, $setting['value'], array('id' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_select_box($elementName, $languages, $setting['value'], array('id' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'passwordbox') { - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_password_box($element_name, $setting['value'], array('id' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_password_box($elementName, $setting['value'], array('id' => $elementId)), $elementName, array('id' => $rowId)); } else if ($type[0] == 'php') { $setting['optionscode'] = substr($setting['optionscode'], 3); - eval("\$setting_code = \"" . $setting['optionscode'] . "\";"); + eval("\$setting_code = \"".$setting['optionscode']."\";"); } else { for ($i=0; $i < count($type); $i++) { - $optionsexp = explode('=', $type[$i]); - if (!$optionsexp[1]) { + $optionsArray = explode('=', $type[$i]); + if (!$optionsArray[1]) { continue; } if ($type[0] == 'select') { - $option_list[$optionsexp[0]] = htmlspecialchars_uni($optionsexp[1]); + $optionList[$optionsArray[0]] = htmlspecialchars_uni($optionsArray[1]); } else if ($type[0] == 'radio') { - if ($setting['value'] == $optionsexp[0]) { - $option_list[$i] = $this_form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, "checked" => 1, 'class' => $element_id)); + if ($setting['value'] == $optionsArray[0]) { + $optionList[$i] = $this_form->generate_radio_button($elementName, $optionsArray[0], htmlspecialchars_uni($optionsArray[1]), array('id' => $elementId.'_'.$i, 'checked' => 1, 'class' => $elementId)); } else { - $option_list[$i] = $this_form->generate_radio_button($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id)); + $optionList[$i] = $this_form->generate_radio_button($elementName, $optionsArray[0], htmlspecialchars_uni($optionsArray[1]), array('id' => $elementId.'_'.$i, 'class' => $elementId)); } } else if($type[0] == 'checkbox') { - if ($setting['value'] == $optionsexp[0]) { - $option_list[$i] = $this_form->generate_check_box($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, "checked" => 1, 'class' => $element_id)); + if ($setting['value'] == $optionsArray[0]) { + $optionList[$i] = $this_form->generate_check_box($elementName, $optionsArray[0], htmlspecialchars_uni($optionsArray[1]), array('id' => $elementId.'_'.$i, 'checked' => 1, 'class' => $elementId)); } else { - $option_list[$i] = $this_form->generate_check_box($element_name, $optionsexp[0], htmlspecialchars_uni($optionsexp[1]), array('id' => $element_id.'_'.$i, 'class' => $element_id)); + $optionList[$i] = $this_form->generate_check_box($elementName, $optionsArray[0], htmlspecialchars_uni($optionsArray[1]), array('id' => $elementId.'_'.$i, 'class' => $elementId)); } } } if ($type[0] == 'select') { - $this_form_container->output_row($this_label, $this_desc, $this_form->generate_select_box($element_name, $option_list, $setting['value'], array('id' => $element_id)), $element_name, array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $this_form->generate_select_box($elementName, $optionList, $setting['value'], array('id' => $elementId)), $elementName, array('id' => $rowId)); } else { - $setting_code = implode('
', $option_list); + $setting_code = implode('
', $optionList); } } if ($setting_code) { - $this_form_container->output_row($this_label, $this_desc, $setting_code, '', array(), array('id' => $row_id)); + $this_form_container->output_row($thisLabel, $thisDescription, $setting_code, '', array(), array('id' => $rowId)); } } diff --git a/Upload/inc/plugins/asb/functions_addon.php b/Upload/inc/plugins/asb/functions_addon.php index e904ed2..eb74761 100644 --- a/Upload/inc/plugins/asb/functions_addon.php +++ b/Upload/inc/plugins/asb/functions_addon.php @@ -13,13 +13,13 @@ * @param string message * @return string message */ -function asb_strip_quotes($message) +function asbStripQuotes($message) { // Assign pattern and replace values. $pattern = array( "#\[quote=([\"']|"|)(.*?)(?:\\1)(.*?)(?:[\"']|")?\](.*?)\[/quote\](\r\n?|\n?)#si", "#\[quote\](.*?)\[\/quote\](\r\n?|\n?)#si", - "#\[\/quote\](\r\n?|\n?)#si" + "#\[\/quote\](\r\n?|\n?)#si", ); do { @@ -35,9 +35,9 @@ function asb_strip_quotes($message) * @param string message * @return string message */ -function asb_strip_url($message) +function asbStripUrls($message) { - $message = ' ' . $message; + $message = ' '.$message; $message = preg_replace("#([\>\s\(\)])(http|https|ftp|news){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", '', $message); $message = preg_replace("#([\>\s\(\)])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", '', $message); return my_substr($message, 1); @@ -51,41 +51,42 @@ function asb_strip_url($message) * @param bool present the id list as SQL IN()? * @return string id list */ -function asb_build_id_list($ids, $field = 'id', $wrap = true) +function asbBuildIdList($ids, $field='id', $wrap=true) { if (strlen($ids) == 0) { return false; } if (strpos($ids, ',') !== false) { - $id_array = explode(',', $ids); - foreach ($id_array as $key => $id) { + $idArray = explode(',', $ids); + + foreach ($idArray as $key => $id) { if((int) $id == 0) { - unset($id_array[$key]); + unset($idArray[$key]); } } - if (count($id_array) > 1) { - $id_list = implode(',', $id_array); - } elseif (count($id_array) == 1) { - $id_list = (int) $id_array[key($id_array)]; + if (count($idArray) > 1) { + $idList = implode(',', $idArray); + } elseif (count($idArray) == 1) { + $idList = (int) $idArray[key($idArray)]; } } else { - $id_list = (int) $ids; + $idList = (int) $ids; } - if (!$id_list) { + if (!$idList) { return false; } if ($wrap && $field) { - $id_list = <<isDot()) { continue; @@ -158,9 +159,9 @@ function asb_get_folder_images($folder, $subfolder = '', $recursive = false) } // get the files from this directory - $sub_files = asb_get_folder_images($folder . '/' . $file->getFilename(), $subfolder . $file->getFilename(), $recursive); - if ($sub_files) { - $filenames .= "{$sep}{$sub_files}"; + $subFiles = asbGetImagesFromPath($folder.'/'.$file->getFilename(), $subfolder.$file->getFilename(), $recursive); + if ($subFiles) { + $filenames .= "{$sep}{$subFiles}"; $sep = ','; } continue; diff --git a/Upload/inc/plugins/asb/install.php b/Upload/inc/plugins/asb/install.php index ed12388..068dfe8 100644 --- a/Upload/inc/plugins/asb/install.php +++ b/Upload/inc/plugins/asb/install.php @@ -26,12 +26,12 @@ function asb_info() $lang->load('asb'); } - $extra_links = '
'; - $settings_link = asb_build_settings_link(); - if ($settings_link) { - if (file_exists(MYBB_ROOT . 'inc/plugins/asb/cleanup.php') && - file_exists(MYBB_ROOT . 'inc/plugins/adv_sidebox/acp_functions.php')) { - $remove_link = << {$lang->asb_remove_old_files_desc}
{$lang->asb_remove_old_files} @@ -40,58 +40,51 @@ function asb_info() } // only show Manage Sideboxes link if active - $plugin_list = $cache->read('plugins'); - $manage_link = ''; - if (!empty($plugin_list['active']) && - is_array($plugin_list['active']) && - in_array('asb', $plugin_list['active'])) { + $pluginList = $cache->read('plugins'); + $manageLink = ''; + if (!empty($pluginList['active']) && + is_array($pluginList['active']) && + in_array('asb', $pluginList['active'])) { $url = ASB_URL; - $manage_link = << {$lang->asb_manage_sideboxes} EOF; } - $settings_link = << - {$settings_link} + {$settingsLink} EOF; - $extra_links = << - {$settings_link} - {$manage_link}{$remove_link} + {$settingsLink} + {$manageLink}{$removeLink}
  • {$lang->asb_help}
  • EOF; - $button_pic = "styles/{$cp_style}/images/asb/donate.png"; - $border_pic = "styles/{$cp_style}/images/asb/pixel.png"; - $asb_description = <<
    - {$custom_boxes} + {$customBoxes} - {$left_boxes} + {$leftBoxes} - {$right_boxes} + {$rightBoxes}
    {$lang->asb_sample_content_line1}
    {$lang->asb_sample_content_line3}
    - -
    - cache['usercp_options'] = str_replace($find, $usercp_option, $templates->cache['usercp_options']); + eval("\$asbShowSideboxes = \"{$templates->get('asb_ucp_show_sidebox_option')}\";"); } /** @@ -437,7 +420,7 @@ function asb_xmlhttp() } // get the ASB core stuff - require_once MYBB_ROOT . 'inc/plugins/asb/functions_addon.php'; + require_once MYBB_ROOT.'inc/plugins/asb/functions_addon.php'; // attempt to load the module and side box requested $module = new SideboxExternalModule($mybb->input['addon']); diff --git a/Upload/inc/plugins/asb/functions.php b/Upload/inc/plugins/asb/functions.php index fb5beb7..2ee0c65 100644 --- a/Upload/inc/plugins/asb/functions.php +++ b/Upload/inc/plugins/asb/functions.php @@ -12,14 +12,14 @@ * * @return bool success/fail */ -function asb_do_checks() +function asbDoStartupChecks() { global $mybb, $theme; - // if the EXCLUDE list isn't empty and this theme is listed . . . - $exclude_list = asb_get_excluded_themes(); - if ($exclude_list && - in_array($theme['tid'], $exclude_list)) { + // if the EXCLUDE list isn't empty and this theme is listed... + $excludedArray = asbGetExcludedThemes(); + if ($excludedArray && + in_array($theme['tid'], $excludedArray)) { // no side boxes for you return false; } @@ -41,7 +41,7 @@ function asb_do_checks() * credit: http://stackoverflow.com/users/1304523/justin-docanto */ if ($mybb->settings['asb_disable_for_mobile'] && - preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"])) { + preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER['HTTP_USER_AGENT'])) { return false; } @@ -53,157 +53,24 @@ function asb_do_checks() * * @return array|bool excluded themes or false */ -function asb_get_excluded_themes($sql = false) +function asbGetExcludedThemes($sql=false) { global $mybb; - $retval = unserialize($mybb->settings['asb_exclude_theme']); - if (!is_array($retval) || - empty($retval)) { - $retval = false; + $returnVal = unserialize($mybb->settings['asb_exclude_theme']); + if (!is_array($returnVal) || + empty($returnVal)) { + $returnVal = false; } if ($sql) { - if ($retval) { - $retval = ' AND pid NOT IN(' . implode(',', $retval) . ')'; + if ($returnVal) { + $returnVal = ' AND pid NOT IN('.implode(',', $returnVal).')'; } else { - $retval = ''; - } - } - return $retval; -} - -/** - * retrieve the cache, rebuilding it if necessary - * - * @return array cache data - */ -function asb_get_cache() -{ - $myCache = AdvancedSideboxCache::getInstance(); - $asb = $myCache->read(); - - // if the cache has never been built or has been marked as changed - // then rebuild and store it - if ((int) $asb['last_run'] == 0 || - $asb['has_changed']) { - asb_build_cache($asb); - $myCache->update(null, $asb); - } - - // returned the cached info - return $asb; -} - -/** - * build all of the relevant info needed to manage side boxes - * - * @param array cache data variable - * @return void - */ -function asb_build_cache(&$asb) -{ - global $db; - - // fresh start - $asb['custom'] = $asb['sideboxes'] = $asb['scripts'] = $asb['all_scripts'] = array(); - - // update the run time and changed flag before we even start - $asb['last_run'] = TIME_NOW; - $asb['has_changed'] = false; - - // get all the active scripts' info - $all_scripts = asb_get_all_scripts(); - - // no scripts, no work to do - if (!is_array($all_scripts) || - empty($all_scripts)) { - return; - } - - // store the script definitions and a master list - foreach ($all_scripts as $filename => $script) { - $asb['scripts'][$filename] = $script; - } - $asb['all_scripts'] = array_keys($all_scripts); - - // load all detected modules - $addons = asb_get_all_modules(); - - // get any custom boxes - $custom = asb_get_all_custom(); - - // get any sideboxes - $sideboxes = asb_get_all_sideboxes(); - - if (!is_array($sideboxes) || - empty($sideboxes)) { - return; - } - - foreach ($sideboxes as $sidebox) { - // build basic data - $scripts = $sidebox->get('scripts'); - $id = (int) $sidebox->get('id'); - $pos = $sidebox->get('position') ? 1 : 0; - $asb['sideboxes'][$id] = $sidebox->get('data'); - $module = $sidebox->get('box_type'); - - // no scripts == all scripts - if (empty($scripts)) { - // add this side box to the 'global' set (to be merged with the current script when applicable) - $scripts = array('global'); - } - - // for each script in which the side box is used, add a pointer and if it is a custom box, cache its contents - foreach ($scripts as $filename) { - // side box from a module? - if (isset($addons[$module]) && - $addons[$module] instanceof SideboxExternalModule) { - // store the module name and all the template vars used - $asb['scripts'][$filename]['sideboxes'][$pos][$id] = $module; - $asb['scripts'][$filename]['template_vars'][$id] = "{$module}_{$id}"; - - // if there are any templates get their names so we can cache them - $templates = $addons[$module]->get('templates'); - if (is_array($templates) && - !empty($templates)) { - foreach ($templates as $template) { - $asb['scripts'][$filename]['templates'][] = $template['title']; - } - } - - // AJAX? - if ($addons[$module]->xmlhttp && - $sidebox->hasSettings) { - $settings = $sidebox->get('settings'); - - // again, default here is off if anything goes wrong - if ($settings['xmlhttp_on']) { - // if all is good add the script building info - $asb['scripts'][$filename]['extra_scripts'][$id]['position'] = $pos; - $asb['scripts'][$filename]['extra_scripts'][$id]['module'] = $module; - $asb['scripts'][$filename]['extra_scripts'][$id]['rate'] = $settings['xmlhttp_on']; - } - } - - if ($addons[$module]->hasScripts) { - foreach ($addons[$module]->get('scripts') as $script) { - $asb['scripts'][$filename]['js'][$script] = $script; - } - } - // side box from a custom box? - } else if(isset($custom[$module]) && - $custom[$module] instanceof CustomSidebox) { - // store the pointer - $asb['scripts'][$filename]['sideboxes'][$pos][$id] = $module; - $asb['scripts'][$filename]['template_vars'][$id] = "{$module}_{$id}"; - - // and cache the contents - $asb['custom'][$module] = $custom[$module]->get('data'); - } + $returnVal = ''; } } + return $returnVal; } /** @@ -212,37 +79,37 @@ function asb_build_cache(&$asb) * @param array script environment info * @return string filename marked up for asb */ -function asb_build_script_filename($this_script = '') +function asbBuildScriptFilename($script='') { - if ($this_script instanceof ScriptInfo) { - $this_script = $this_script->get('data'); + if ($script instanceof ScriptInfo) { + $script = $script->get('data'); } // no info means use the MyBB values - if (!is_array($this_script) || - empty($this_script)) { + if (!is_array($script) || + empty($script)) { global $mybb; - $this_script = array( - "filename" => THIS_SCRIPT, - "action" => $mybb->input['action'], - "page" => $mybb->input['page'] + $script = array( + 'filename' => THIS_SCRIPT, + 'action' => $mybb->input['action'], + 'page' => $mybb->input['page'], ); } - $this_script = array_map('trim', $this_script); + $script = array_map('trim', $script); - // if there is nothing to work with . . . - if (!$this_script['filename']) { + // if there is nothing to work with... + if (!$script['filename']) { return; } // build each piece - $filename = $this_script['filename']; + $filename = $script['filename']; foreach (array('action', 'page') as $key) { - if (!$this_script[$key]) { + if (!$script[$key]) { continue; } - $filename .= "&{$key}={$this_script[$key]}"; + $filename .= "&{$key}={$script[$key]}"; } return $filename; } @@ -255,13 +122,13 @@ function asb_build_script_filename($this_script = '') * should be loaded along with the other info * @return array script info */ -function asb_get_this_script($asb, $get_all = false) +function asbGetCurrentScript($asb, $getAll=false) { global $mybb; if (is_array($asb['scripts'][THIS_SCRIPT]) && !empty($asb['scripts'][THIS_SCRIPT])) { - $return_array = $asb['scripts'][THIS_SCRIPT]; + $returnArray = $asb['scripts'][THIS_SCRIPT]; } foreach (array('action', 'page') as $key) { @@ -270,34 +137,34 @@ function asb_get_this_script($asb, $get_all = false) continue; } - $filename = THIS_SCRIPT . "&{$key}={$mybb->input[$key]}"; + $filename = THIS_SCRIPT."&{$key}={$mybb->input[$key]}"; if (!is_array($asb['scripts'][$filename]) || empty($asb['scripts'][$filename])) { continue; } - $return_array = $asb['scripts'][$filename]; + $returnArray = $asb['scripts'][$filename]; } - if (empty($return_array) || - !is_array($return_array)) { + if (empty($returnArray) || + !is_array($returnArray)) { return; } // 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']; + $returnArray['template_vars'] = array_merge((array) $asb['scripts']['global']['template_vars'], (array) $returnArray['template_vars']); + $returnArray['extra_scripts'] = (array) $asb['scripts']['global']['extra_scripts'] + (array) $returnArray['extra_scripts']; + $returnArray['js'] = (array) $asb['scripts']['global']['js'] + (array) $returnArray['js']; // the template handler does not need side boxes and templates - if (!$get_all) { - return $return_array; + if (!$getAll) { + return $returnArray; } // asb_start() and asb_initialize() do - $return_array['sideboxes'][0] = asb_merge_sidebox_list($asb, (array) $asb['scripts']['global']['sideboxes'][0], (array) $return_array['sideboxes'][0]); - $return_array['sideboxes'][1] = asb_merge_sidebox_list($asb, (array) $asb['scripts']['global']['sideboxes'][1], (array) $return_array['sideboxes'][1]); - $return_array['templates'] = array_merge((array) $asb['scripts']['global']['templates'], (array) $return_array['templates']); - return $return_array; + $returnArray['sideboxes'][0] = asbMergeSideBoxList($asb, (array) $asb['scripts']['global']['sideboxes'][0], (array) $returnArray['sideboxes'][0]); + $returnArray['sideboxes'][1] = asbMergeSideBoxList($asb, (array) $asb['scripts']['global']['sideboxes'][1], (array) $returnArray['sideboxes'][1]); + $returnArray['templates'] = array_merge((array) $asb['scripts']['global']['templates'], (array) $returnArray['templates']); + return $returnArray; } /** @@ -307,12 +174,12 @@ function asb_get_this_script($asb, $get_all = false) * @param array two or more arrays of side box ids => module names * @return array an array with the merged and sorted arrays */ -function asb_merge_sidebox_list($asb) +function asbMergeSideBoxList($asb) { // allow for variable amount of arguments $args = func_get_args(); - // if there aren't at least two arrays to merge . . . + // if there aren't at least two arrays to merge... if (count($args) <= 2) { // return the single array if it exists if ($args[1]) { @@ -326,21 +193,21 @@ function asb_merge_sidebox_list($asb) array_shift($args); // merge all the passed arrays - $merged_array = array(); + $mergedArray = array(); foreach ($args as $sideboxes) { foreach ($sideboxes as $sidebox => $module) { - $merged_array[$sidebox] = $module; + $mergedArray[$sidebox] = $module; } } // now sort them according to the original side box's display order - $return_array = array(); + $returnArray = array(); foreach ($asb['sideboxes'] as $sidebox => $module) { - if (isset($merged_array[$sidebox])) { - $return_array[$sidebox] = $module['box_type']; + if (isset($mergedArray[$sidebox])) { + $returnArray[$sidebox] = $module['box_type']; } } - return $return_array; + return $returnArray; } /** @@ -349,37 +216,37 @@ function asb_merge_sidebox_list($asb) * @param array allowed groups * @return bool allowed/not */ -function asb_check_user_permissions($good_groups) +function asbCheckUserPermissions($allowedGroups) { // no groups = all groups says wildy - if (empty($good_groups)) { + if (empty($allowedGroups)) { return true; } // array-ify the list if necessary - if (!is_array($good_groups)) { - $good_groups = explode(',', $good_groups); + if (!is_array($allowedGroups)) { + $allowedGroups = explode(',', $allowedGroups); } global $mybb; if ($mybb->user['uid'] == 0) { // guests don't require as much work ;-) - return in_array(0, $good_groups); + return in_array(0, $allowedGroups); } // get all the user's groups in one array - $users_groups = array($mybb->user['usergroup']); + $usersGroups = array($mybb->user['usergroup']); if ($mybb->user['additionalgroups']) { - $adtl_groups = explode(',', $mybb->user['additionalgroups']); - $users_groups = array_merge($users_groups, $adtl_groups); + $additionalGroups = explode(',', $mybb->user['additionalgroups']); + $usersGroups = array_merge($usersGroups, $additionalGroups); } /* - * if any overlaps occur then they will be in $test_array, + * if any overlaps occur then they will be in $testArray, * empty returns true/false so !empty = true for allow and false for disallow */ - $test_array = array_intersect($users_groups, $good_groups); - return !empty($test_array); + $testArray = array_intersect($usersGroups, $allowedGroups); + return !empty($testArray); } /** @@ -388,14 +255,14 @@ function asb_check_user_permissions($good_groups) * @param SideboxObject|array side box * @return string|bool html or false */ -function asb_build_sidebox_content($this_box) +function asbBuildSideBoxContent($thisBox) { // need good info - if ($this_box instanceof SideboxObject) { - $data = $this_box->get('data'); - } else if (is_array($this_box) && - !empty($this_box)) { - $data = $this_box; + if ($thisBox instanceof SideboxObject) { + $data = $thisBox->get('data'); + } else if (is_array($thisBox) && + !empty($thisBox)) { + $data = $thisBox; } else { return false; } @@ -408,16 +275,16 @@ function asb_build_sidebox_content($this_box) } // build the template variable - $content = '{$' . "{$box_type}_{$id}" . '}'; + $content = '{$'."{$box_type}_{$id}".'}'; - // if we are building header and expander . . . + // if we are building header and expander... if ($wrap_content) { global $mybb, $templates, $theme, $collapsed; // element info $sidebox['expcolimage_id'] = "{$box_type}_{$id}_img"; $sidebox['expdisplay_id'] = "{$box_type}_{$id}_e"; - $sidebox['name'] = "{$id}_{$box_type}_" . TIME_NOW; + $sidebox['name'] = "{$id}_{$box_type}_".TIME_NOW; $sidebox['class'] = $sidebox['id'] = "{$box_type}_main_{$id}"; $sidebox['content'] = $content; $sidebox['title'] = $title; @@ -440,9 +307,9 @@ function asb_build_sidebox_content($this_box) $expcolimage = 'collapse.png'; $expaltext = '[-]'; } - eval("\$expander = \"" . $templates->get('asb_expander') . "\";"); + eval("\$expander = \"{$templates->get('asb_expander')}\";"); } - eval("\$content = \"" . $templates->get('asb_wrapped_sidebox') . "\";"); + eval("\$content = \"{$templates->get('asb_wrapped_sidebox')}\";"); } // if there is anything to return @@ -465,9 +332,9 @@ function asb_build_sidebox_content($this_box) * * @return array SideboxExternalModule */ -function asb_get_all_modules() +function asbGetAllModules() { - $return_array = array(); + $returnArray = array(); // load all detected modules foreach (new DirectoryIterator(ASB_MODULES_DIR) as $file) { @@ -489,9 +356,9 @@ function asb_get_all_modules() $module = substr($filename, 0, strlen($filename) - 4); // attempt to load the module - $return_array[$module] = new SideboxExternalModule($module); + $returnArray[$module] = new SideboxExternalModule($module); } - return $return_array; + return $returnArray; } /** @@ -499,20 +366,20 @@ function asb_get_all_modules() * * @return array CustomSidebox */ -function asb_get_all_custom() +function asbGetAllCustomBoxes() { global $db; // get any custom boxes - $return_array = array(); + $returnArray = array(); $query = $db->simple_select('asb_custom_sideboxes'); if ($db->num_rows($query) > 0) { while ($data = $db->fetch_array($query)) { - $return_array['asb_custom_' . $data['id']] = new CustomSidebox($data); + $returnArray['asb_custom_'.$data['id']] = new CustomSidebox($data); } } - return $return_array; + return $returnArray; } /** @@ -521,31 +388,31 @@ function asb_get_all_custom() * @param string script filter * @return array SideboxObject */ -function asb_get_all_sideboxes($good_script = '') +function asbGetAllSideBoxes($allowedScript='') { global $db; // get any side boxes - $return_array = array(); + $returnArray = array(); - $query = $db->simple_select('asb_sideboxes', '*', '', array("order_by" => 'display_order', "order_dir" => 'ASC')); + $query = $db->simple_select('asb_sideboxes', '*', '', array('order_by' => 'display_order', 'order_dir' => 'ASC')); if ($db->num_rows($query) > 0) { while ($data = $db->fetch_array($query)) { $sidebox = new SideboxObject($data); - if ($good_script) { + if ($allowedScript) { $scripts = $sidebox->get('scripts'); if (!empty($scripts) && - !in_array($good_script, $scripts)) { + !in_array($allowedScript, $scripts)) { continue; } } // create the object and build basic data - $return_array[$data['id']] = $sidebox; + $returnArray[$data['id']] = $sidebox; } } - return $return_array; + return $returnArray; } /** @@ -553,21 +420,21 @@ function asb_get_all_sideboxes($good_script = '') * * @return array script data */ -function asb_get_all_scripts() +function asbGetAllScripts() { global $db; // get all the active scripts' info - $return_array = array(); + $returnArray = array(); $query = $db->simple_select('asb_script_info', '*', "active='1'"); if ($db->num_rows($query) > 0) { - while ($this_script = $db->fetch_array($query)) { - $filename = asb_build_script_filename($this_script); - $return_array[$filename] = $this_script; + while ($script = $db->fetch_array($query)) { + $filename = asbBuildScriptFilename($script); + $returnArray[$filename] = $script; } } - return $return_array; + return $returnArray; } /** @@ -575,7 +442,7 @@ function asb_get_all_scripts() * * @return string|bool html or false */ -function asb_get_all_themes($full = false) +function asbGetAllThemes($full=false) { global $db; @@ -583,11 +450,11 @@ function asb_get_all_themes($full = false) if (!is_array($themeList)) { if ($full != true) { - $excluded_themes = asb_get_excluded_themes(true); + $excludedThemes = asbGetExcludedThemes(true); } // get all the themes that are not MasterStyles - $query = $db->simple_select('themes', 'tid, name', "NOT pid='0'{$excluded_themes}"); + $query = $db->simple_select('themes', 'tid, name', "NOT pid='0'{$excludedThemes}"); $themeList = array(); while ($thisTheme = $db->fetch_array($query)) { diff --git a/Upload/inc/plugins/asb/functions_acp.php b/Upload/inc/plugins/asb/functions_acp.php index 1f947d8..fe32a1d 100644 --- a/Upload/inc/plugins/asb/functions_acp.php +++ b/Upload/inc/plugins/asb/functions_acp.php @@ -13,7 +13,7 @@ * @param string topic keyword * @return string html */ -function asb_build_help_link($topic = '') +function asbBuildHelpLink($topic='') { global $mybb, $lang, $html, $cp_style; @@ -45,7 +45,7 @@ function asb_build_help_link($topic = '') break; } - return $html->link($url, $lang->asb_help, array("target" => '_blank', "style" => 'font-weight: bold;', "icon" => "styles/{$cp_style}/images/asb/help.png", "title" => $lang->asb_help), array("alt" => '?', "title" => $lang->asb_help, "style" => 'margin-bottom: -3px;')); + return $html->link($url, $lang->asb_help, array('target' => '_blank', 'style' => 'font-weight: bold;', 'icon' => "styles/{$cp_style}/images/asb/help.png", 'title' => $lang->asb_help), array('alt' => '?', 'title' => $lang->asb_help, 'style' => 'margin-bottom: -3px;')); } /** @@ -53,13 +53,13 @@ function asb_build_help_link($topic = '') * * @return string html */ -function asb_build_settings_menu_link() +function asbBuildSettingsMenuLink() { global $mybb, $lang, $html, $cp_style; - $settings_url = asb_build_settings_url(asb_get_settingsgroup()); - $settings_link = $html->link($settings_url, $lang->asb_plugin_settings, array("icon" => "styles/{$cp_style}/images/asb/settings.png", "style" => 'font-weight: bold;', "title" => $lang->asb_plugin_settings), array("alt" => 'S', "style" => 'margin-bottom: -3px;')); - return $settings_link; + $settingsUrl = asbBuildSettingsUrl(asbGetSettingsGroup()); + $settingsLink = $html->link($settingsUrl, $lang->asb_plugin_settings, array('icon' => "styles/{$cp_style}/images/asb/settings.png", 'style' => 'font-weight: bold;', 'title' => $lang->asb_plugin_settings), array('alt' => 'S', 'style' => 'margin-bottom: -3px;')); + return $settingsLink; } /** @@ -68,48 +68,48 @@ function asb_build_settings_menu_link() * @param string current tab * @return void */ -function asb_output_tabs($current) +function asbOutputTabs($current) { global $page, $lang, $mybb, $html; // set up tabs - $sub_tabs['asb'] = array( - 'title' => $lang->asb_manage_sideboxes, - 'link' => $html->url(), - 'description' => $lang->asb_manage_sideboxes_desc + $tabs['asb'] = array( + 'title' => $lang->asb_manage_sideboxes, + 'link' => $html->url(), + 'description' => $lang->asb_manage_sideboxes_desc, ); - $sub_tabs['asb_custom'] = array( - 'title' => $lang->asb_custom_boxes, - 'link' => $html->url(array("action" => 'custom_boxes')), - 'description' => $lang->asb_custom_boxes_desc + $tabs['asb_custom'] = array( + 'title' => $lang->asb_custom_boxes, + 'link' => $html->url(array('action' => 'custom_boxes')), + 'description' => $lang->asb_custom_boxes_desc, ); if (in_array($current, array('asb_add_custom', 'asb_custom'))) { - $sub_tabs['asb_add_custom'] = array( - 'title' => $lang->asb_add_custom, - 'link' => $html->url(array("action" => 'custom_boxes', "mode" => 'edit')), - 'description' => $lang->asb_add_custom_desc + $tabs['asb_add_custom'] = array( + 'title' => $lang->asb_add_custom, + 'link' => $html->url(array('action' => 'custom_boxes', 'mode' => 'edit')), + 'description' => $lang->asb_add_custom_desc, ); } - $sub_tabs['asb_scripts'] = array( - 'title' => $lang->asb_manage_scripts, - 'link' => $html->url(array("action" => 'manage_scripts')), - 'description' => $lang->asb_manage_scripts_desc + $tabs['asb_scripts'] = array( + 'title' => $lang->asb_manage_scripts, + 'link' => $html->url(array('action' => 'manage_scripts')), + 'description' => $lang->asb_manage_scripts_desc, ); if (in_array($current, array('asb_edit_script', 'asb_scripts'))) { - $sub_tabs['asb_edit_script'] = array( - 'title' => $lang->asb_edit_script, - 'link' => $html->url(array("action" => 'manage_scripts', "mode" => 'edit')), - 'description' => $lang->asb_edit_script_desc + $tabs['asb_edit_script'] = array( + 'title' => $lang->asb_edit_script, + 'link' => $html->url(array('action' => 'manage_scripts', 'mode' => 'edit')), + 'description' => $lang->asb_edit_script_desc, ); } - $sub_tabs['asb_modules'] = array( - 'title' => $lang->asb_manage_modules, - 'link' => $html->url(array("action" => 'manage_modules')), - 'description' => $lang->asb_manage_modules_desc + $tabs['asb_modules'] = array( + 'title' => $lang->asb_manage_modules, + 'link' => $html->url(array('action' => 'manage_modules')), + 'description' => $lang->asb_manage_modules_desc, ); - $page->output_nav_tabs($sub_tabs, $current); + $page->output_nav_tabs($tabs, $current); } /** @@ -118,11 +118,11 @@ function asb_output_tabs($current) * @param string current page * @return void */ -function asb_output_footer($page_key) +function asbOutputFooter($pageKey) { global $page; - echo(asb_build_footer_menu($page_key)); + echo(asbBuildFooterMenu($pageKey)); $page->output_footer(); } @@ -132,27 +132,27 @@ function asb_output_footer($page_key) * @param string topic key * @return string html */ -function asb_build_footer_menu($page_key = '') +function asbBuildFooterMenu($pageKey='') { global $mybb; - if (!$page_key) { - $page_key = 'manage_sideboxes'; + if (!$pageKey) { + $pageKey = 'manage_sideboxes'; } - $help_link = ' ' . asb_build_help_link($page_key); - $settings_link = ' ' . asb_build_settings_menu_link(); + $helpLink = ' '.asbBuildHelpLink($pageKey); + $settingsLink = ' '.asbBuildSettingsMenuLink(); - if ($page_key == 'manage_sideboxes') { - $filter_links = asb_build_filter_selector($mybb->input['page']); + if ($pageKey == 'manage_sideboxes') { + $filterSelector = asbBuildFilterSelector($mybb->input['page']); } return << -{$filter_links} - {$settings_link} - {$help_link} +{$filterSelector} + {$settingsLink} + {$helpLink} EOF; @@ -164,24 +164,24 @@ function asb_build_footer_menu($page_key = '') * @param int id * @return string html */ -function asb_build_permissions_table($sidebox) +function asbBuildPermissionsTable($sidebox) { - global $lang, $all_scripts; + global $lang, $allScripts; if ($sidebox instanceof SideboxObject == false || !$sidebox->isValid()) { return $lang->asb_invalid_sidebox; } - if (!$all_scripts) { + if (!$allScripts) { return $lang->asb_no_active_scripts; } - $visibility_rows = asb_build_visibility_rows($sidebox, $group_count, $global); - $theme_list = asb_build_theme_visibility_list($sidebox, $group_count + 1, $global); + $visibility_rows = asbBuildVisibilityRows($sidebox, $group_count, $global); + $themeList = asbBuildThemeVisibilityList($sidebox, $group_count + 1, $global); return <<{$visibility_rows}{$theme_list} +{$visibility_rows}{$themeList}
    EOF; } @@ -194,14 +194,14 @@ function asb_build_permissions_table($sidebox) * @param bool global visibility * @return string html */ -function asb_build_visibility_rows($sidebox, &$group_count, &$global) +function asbBuildVisibilityRows($sidebox, &$group_count, &$global) { - global $db, $lang, $all_scripts; + global $db, $lang, $allScripts; static $options; - if (!is_array($all_scripts) || - empty($all_scripts)) { + if (!is_array($allScripts) || + empty($allScripts)) { return $lang->asb_no_active_scripts; } @@ -229,7 +229,7 @@ function asb_build_visibility_rows($sidebox, &$group_count, &$global) } elseif (isset($groups[0]) && strlen($groups[0]) == 0) { return "
    {$lang->asb_all_scripts_deactivated}
    {$theme_list}{$themeList}
    - {$lang->asb_description1}

    {$lang->asb_description2}{$extra_links} + {$lang->asb_description1}

    {$lang->asb_description2}{$extraLinks}
    {$lang->asb_logo}

    -
    - - - - -
    +
    EOF; } else { - $asb_description = $lang->asb_description1; + $asbDescription = $lang->asb_description1; } $name = << $name, - "description" => $asb_description, - "website" => 'https://github.com/WildcardSearch/Advanced-Sidebox', - "author" => $author, - "authorsite" => 'http://www.rantcentralforums.com', - "version" => ASB_VERSION, - "compatibility" => '18*', - "codename" => 'asb', + 'name' => $name, + 'description' => $asbDescription, + 'website' => 'https://github.com/WildcardSearch/Advanced-Sidebox', + 'author' => $author, + 'authorsite' => 'http://www.rantcentralforums.com', + 'version' => ASB_VERSION, + 'compatibility' => '18*', + 'codename' => 'asb', ); } @@ -121,7 +114,7 @@ function asb_info() */ function asb_is_installed() { - return asb_get_settingsgroup(); + return asbGetSettingsGroup(); } /** @@ -141,14 +134,14 @@ function asb_install() AdvancedSideboxInstaller::getInstance()->install(); - $addons = asb_get_all_modules(); + $addons = asbGetAllModules(); foreach ($addons as $addon) { $addon->install(); } - asb_create_script_info(); + asbCreateScriptInfo(); - @unlink(MYBB_ROOT . 'inc/plugins/adv_sidebox.php'); + @unlink(MYBB_ROOT.'inc/plugins/adv_sidebox.php'); } /** @@ -163,18 +156,21 @@ function asb_activate() $myCache = AdvancedSideboxCache::getInstance(); - // if we just upgraded . . . + // if we just upgraded... $asbOldVersion = $myCache->getVersion(); if (isset($asbOldVersion) && $asbOldVersion && version_compare($asbOldVersion, ASB_VERSION, '<')) { - require_once MYBB_ROOT . 'inc/plugins/asb/upgrade.php'; + require_once MYBB_ROOT.'inc/plugins/asb/upgrade.php'; } $myCache->setVersion(ASB_VERSION); // change the permissions to on by default change_admin_permission('config', 'asb'); + + require_once MYBB_ROOT . '/inc/adminfunctions_templates.php'; + find_replace_templatesets('usercp_options', "#" . preg_quote('{$board_style}') . "#i", '{$asbShowSideboxes}{$board_style}'); } /** @@ -186,6 +182,9 @@ function asb_deactivate() { // remove the permissions change_admin_permission('config', 'asb', -1); + + require_once MYBB_ROOT . '/inc/adminfunctions_templates.php'; + find_replace_templatesets('usercp_options', "#" . preg_quote('{$asbShowSideboxes}') . "#i", ''); } /** @@ -204,7 +203,7 @@ function asb_uninstall() global $mybb; // remove the modules first - $addons = asb_get_all_modules(); + $addons = asbGetAllModules(); // if there are add-on modules installed if (is_array($addons)) { @@ -230,21 +229,18 @@ function asb_uninstall() * * @return int gid */ -function asb_get_settingsgroup() +function asbGetSettingsGroup() { - static $asb_settings_gid; + static $gid; // if we have already stored the value - if (isset($asb_settings_gid)) { - // don't waste a query - $gid = (int) $asb_settings_gid; - } else { + if (!isset($gid)) { global $db; - // otherwise we will have to query the db $query = $db->simple_select('settinggroups', 'gid', "name='asb_settings'"); $gid = (int) $db->fetch_field($query, 'gid'); } + return $gid; } @@ -254,10 +250,10 @@ function asb_get_settingsgroup() * @param int settings group id * @return string url */ -function asb_build_settings_url($gid) +function asbBuildSettingsUrl($gid) { if ($gid) { - return 'index.php?module=config-settings&action=change&gid=' . $gid; + return 'index.php?module=config-settings&action=change&gid='.$gid; } } @@ -266,7 +262,7 @@ function asb_build_settings_url($gid) * * @return string html */ -function asb_build_settings_link() +function asbBuildSettingsLink() { global $lang; @@ -274,12 +270,12 @@ function asb_build_settings_link() $lang->load('asb'); } - $gid = asb_get_settingsgroup(); + $gid = asbGetSettingsGroup(); // does the group exist? if ($gid) { // if so build the URL - $url = asb_build_settings_url($gid); + $url = asbBuildSettingsUrl($gid); // did we get a URL? if ($url) { @@ -296,96 +292,96 @@ function asb_build_settings_link() * @param bool return associative array? * @return array|true see above dependency */ -function asb_create_script_info($return = false) +function asbCreateScriptInfo($return=false) { $scripts = array( - "index" => array( - "title" => 'Index', - "filename" => 'index.php', - "template_name" => 'index', - "hook" => 'index_start', - "find_top" => '{$header}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'index' => array( + 'title' => 'Index', + 'filename' => 'index.php', + 'template_name' => 'index', + 'hook' => 'index_start', + 'find_top' => '{$header}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "forumdisplay" => array( - "title" => 'Forum Display', - "filename" => 'forumdisplay.php', - "template_name" => 'forumdisplay_threadlist', - "hook" => 'forumdisplay_start', - "find_top" => '
    + 'forumdisplay' => array( + 'title' => 'Forum Display', + 'filename' => 'forumdisplay.php', + 'template_name' => 'forumdisplay_threadlist', + 'hook' => 'forumdisplay_start', + 'find_top' => '
    {$newthread}
    ', - "find_bottom" => '{$inline_edit_js}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'find_bottom' => '{$inline_edit_js}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "showthread" => array( - "title" => 'Show Thread', - "filename" => 'showthread.php', - "template_name" => 'showthread', - "hook" => 'showthread_start', - "find_top" => '{$ratethread}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'showthread' => array( + 'title' => 'Show Thread', + 'filename' => 'showthread.php', + 'template_name' => 'showthread', + 'hook' => 'showthread_start', + 'find_top' => '{$ratethread}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "member" => array( - "title" => 'Member Profile', - "filename" => 'member.php', - "action" => 'profile', - "template_name" => 'member_profile', - "hook" => 'member_profile_start', - "find_top" => '{$header}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'member' => array( + 'title' => 'Member Profile', + 'filename' => 'member.php', + 'action' => 'profile', + 'template_name' => 'member_profile', + 'hook' => 'member_profile_start', + 'find_top' => '{$header}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "memberlist" => array( - "title" => 'Member List', - "filename" => 'memberlist.php', - "template_name" => 'memberlist', - "hook" => 'memberlist_start', - "find_top" => '{$multipage}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'memberlist' => array( + 'title' => 'Member List', + 'filename' => 'memberlist.php', + 'template_name' => 'memberlist', + 'hook' => 'memberlist_start', + 'find_top' => '{$multipage}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "showteam" => array( - "title" => 'Forum Team', - "filename" => 'showteam.php', - "template_name" => 'showteam', - "hook" => 'showteam_start', - "find_top" => '{$header}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'showteam' => array( + 'title' => 'Forum Team', + 'filename' => 'showteam.php', + 'template_name' => 'showteam', + 'hook' => 'showteam_start', + 'find_top' => '{$header}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "stats" => array( - "title" => 'Statistics', - "filename" => 'stats.php', - "template_name" => 'stats', - "hook" => 'stats_start', - "find_top" => '{$header}', - "find_bottom" => '{$footer}', - "replace_all" => 0, - "eval" => 0, - "active" => 1, + 'stats' => array( + 'title' => 'Statistics', + 'filename' => 'stats.php', + 'template_name' => 'stats', + 'hook' => 'stats_start', + 'find_top' => '{$header}', + 'find_bottom' => '{$footer}', + 'replace_all' => 0, + 'eval' => 0, + 'active' => 1, ), - "portal" => array( - "title" => 'Portal', - "filename" => 'portal.php', - "template_name" => 'portal', - "hook" => 'portal_start', - "replace_all" => 1, - "replacement" => << array( + 'title' => 'Portal', + 'filename' => 'portal.php', + 'template_name' => 'portal', + 'hook' => 'portal_start', + 'replace_all' => 1, + 'replacement' => << {\$mybb->settings['bbname']} @@ -401,22 +397,23 @@ function asb_create_script_info($return = false) EOF , - "eval" => 0, - "active" => 1, + 'eval' => 0, + 'active' => 1, ), ); if ($return == false) { foreach ($scripts as $info) { - $this_script = new ScriptInfo($info); - $this_script->save(); + $script = new ScriptInfo($info); + $script->save(); } + return true; } else { foreach ($scripts as $key => $info) { - $ret_scripts[$key] = new ScriptInfo($info); + $returnArray[$key] = new ScriptInfo($info); } - return $ret_scripts; // upgrade script will save these script defs + return $returnArray; // upgrade script will save these script defs } } @@ -425,18 +422,18 @@ function asb_create_script_info($return = false) * * @return string|bool html or false */ -function asb_build_theme_exclude_select() +function asbBuildThemeExcludeSelect() { global $lang; if (!$lang->asb) { $lang->load('asb'); } - $all_themes = asb_get_all_themes(true); + $allThemes = asbGetAllThemes(true); - $theme_count = min(5, count($all_themes)); - if ($theme_count == 0) { - return $theme_select = << @@ -446,18 +443,18 @@ function asb_build_theme_exclude_select() } // Create an option for each theme and insert code to unserialize each option and 'remember' settings - foreach ($all_themes as $tid => $name) { + foreach ($allThemes as $tid => $name) { $name = addcslashes($name, '"'); - $theme_select .= <<{$name} + $themeSelect .= <<{$name} EOF; } // put it all together return << -{$theme_select} + EOF; diff --git a/Upload/inc/plugins/asb/install_data.php b/Upload/inc/plugins/asb/install_data.php index 53f467a..0d61fa3 100644 --- a/Upload/inc/plugins/asb/install_data.php +++ b/Upload/inc/plugins/asb/install_data.php @@ -9,210 +9,210 @@ $tables = array( 'pgsql' => array( - "asb_sideboxes" => array( - "id" => 'SERIAL', - "display_order" => 'INT NOT NULL', - "box_type" => 'VARCHAR(25) NOT NULL', - "title" => 'TEXT', - "title_link" => 'VARCHAR(128) NOT NULL', - "position" => 'INT', - "scripts" => 'TEXT', - "groups" => 'TEXT', - "themes" => 'TEXT', - "settings" => 'TEXT', - "wrap_content" => 'INT', - "dateline" => 'INT NOT NULL, PRIMARY KEY(id)' + 'asb_sideboxes' => array( + 'id' => 'SERIAL', + 'display_order' => 'INT NOT NULL', + 'box_type' => 'VARCHAR(25) NOT NULL', + 'title' => 'TEXT', + 'title_link' => 'VARCHAR(128) NOT NULL', + 'position' => 'INT', + 'scripts' => 'TEXT', + 'groups' => 'TEXT', + 'themes' => 'TEXT', + 'settings' => 'TEXT', + 'wrap_content' => 'INT', + 'dateline' => 'INT NOT NULL, PRIMARY KEY(id)', ), - "asb_custom_sideboxes" => array( - "id" => 'SERIAL', - "title" => 'VARCHAR(32) NOT NULL', - "description" => 'VARCHAR(128) NOT NULL', - "wrap_content" => 'INT', - "content" => 'TEXT', - "dateline" => 'INT NOT NULL, PRIMARY KEY(id)' + 'asb_custom_sideboxes' => array( + 'id' => 'SERIAL', + 'title' => 'VARCHAR(32) NOT NULL', + 'description' => 'VARCHAR(128) NOT NULL', + 'wrap_content' => 'INT', + 'content' => 'TEXT', + 'dateline' => 'INT NOT NULL, PRIMARY KEY(id)', ), - "asb_script_info" => array( - "id" => 'SERIAL', - "title" => 'VARCHAR(32) NOT NULL', - "filename" => 'VARCHAR(32) NOT NULL', - "action" => 'VARCHAR(32) NOT NULL', - "page" => 'VARCHAR(32) NOT NULL', - "width_left" => 'INT', - "width_right" => 'INT', - "template_name" => 'VARCHAR(128) NOT NULL', - "hook" => 'VARCHAR(128) NOT NULL', - "find_top" => 'TEXT', - "find_bottom" => 'TEXT', - "replace_all" => 'INT', - "replacement" => 'TEXT', - "replacement_template" => 'VARCHAR(128) NOT NULL', - "eval" => 'INT', - "active" => 'INT', - "dateline" => 'INT NOT NULL, PRIMARY KEY(id)' + 'asb_script_info' => array( + 'id' => 'SERIAL', + 'title' => 'VARCHAR(32) NOT NULL', + 'filename' => 'VARCHAR(32) NOT NULL', + 'action' => 'VARCHAR(32) NOT NULL', + 'page' => 'VARCHAR(32) NOT NULL', + 'width_left' => 'INT', + 'width_right' => 'INT', + 'template_name' => 'VARCHAR(128) NOT NULL', + 'hook' => 'VARCHAR(128) NOT NULL', + 'find_top' => 'TEXT', + 'find_bottom' => 'TEXT', + 'replace_all' => 'INT', + 'replacement' => 'TEXT', + 'replacement_template' => 'VARCHAR(128) NOT NULL', + 'eval' => 'INT', + 'active' => 'INT', + 'dateline' => 'INT NOT NULL, PRIMARY KEY(id)', ), ), - "asb_sideboxes" => array( - "id" => 'INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY', - "display_order" => 'INT(10) NOT NULL', - "box_type" => 'VARCHAR(25) NOT NULL', - "title" => 'TEXT', - "title_link" => 'VARCHAR(128) NOT NULL', - "position" => 'INT(2)', - "scripts" => 'TEXT', - "groups" => 'TEXT', - "themes" => 'TEXT', - "settings" => 'TEXT', - "wrap_content" => 'INT(1)', - "dateline" => 'INT(10)' + 'asb_sideboxes' => array( + 'id' => 'INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY', + 'display_order' => 'INT(10) NOT NULL', + 'box_type' => 'VARCHAR(25) NOT NULL', + 'title' => 'TEXT', + 'title_link' => 'VARCHAR(128) NOT NULL', + 'position' => 'INT(2)', + 'scripts' => 'TEXT', + 'groups' => 'TEXT', + 'themes' => 'TEXT', + 'settings' => 'TEXT', + 'wrap_content' => 'INT(1)', + 'dateline' => 'INT(10)', ), - "asb_custom_sideboxes" => array( - "id" => 'INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY', - "title" => 'VARCHAR(32) NOT NULL', - "description" => 'VARCHAR(128) NOT NULL', - "wrap_content" => 'INT(1)', - "content" => 'TEXT', - "dateline" => 'INT(10)' + 'asb_custom_sideboxes' => array( + 'id' => 'INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY', + 'title' => 'VARCHAR(32) NOT NULL', + 'description' => 'VARCHAR(128) NOT NULL', + 'wrap_content' => 'INT(1)', + 'content' => 'TEXT', + 'dateline' => 'INT(10)', ), - "asb_script_info" => array( - "id" => 'INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY', - "title" => 'VARCHAR(32) NOT NULL', - "filename" => 'VARCHAR(32) NOT NULL', - "action" => 'VARCHAR(32) NOT NULL', - "page" => 'VARCHAR(32) NOT NULL', - "width_left" => 'INT(2)', - "width_right" => 'INT(2)', - "template_name" => 'VARCHAR(128) NOT NULL', - "hook" => 'VARCHAR(128) NOT NULL', - "find_top" => 'TEXT', - "find_bottom" => 'TEXT', - "replace_all" => 'INT(1)', - "replacement" => 'TEXT', - "replacement_template" => 'VARCHAR(128) NOT NULL', - "eval" => 'INT(1)', - "active" => 'INT(1)', - "dateline" => 'INT(10)' + 'asb_script_info' => array( + 'id' => 'INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY', + 'title' => 'VARCHAR(32) NOT NULL', + 'filename' => 'VARCHAR(32) NOT NULL', + 'action' => 'VARCHAR(32) NOT NULL', + 'page' => 'VARCHAR(32) NOT NULL', + 'width_left' => 'INT(2)', + 'width_right' => 'INT(2)', + 'template_name' => 'VARCHAR(128) NOT NULL', + 'hook' => 'VARCHAR(128) NOT NULL', + 'find_top' => 'TEXT', + 'find_bottom' => 'TEXT', + 'replace_all' => 'INT(1)', + 'replacement' => 'TEXT', + 'replacement_template' => 'VARCHAR(128) NOT NULL', + 'eval' => 'INT(1)', + 'active' => 'INT(1)', + 'dateline' => 'INT(10)', ), ); $columns = array( 'pgsql' => array( - "users" => array( - "show_sidebox" => 'INT DEFAULT 1', + 'users' => array( + 'show_sidebox' => 'INT DEFAULT 1', ), ), - "users" => array( - "show_sidebox" => 'INT(1) DEFAULT 1', + 'users' => array( + 'show_sidebox' => 'INT(1) DEFAULT 1', ), ); -$update_themes_link = ""; +$updateThemeExcludeLink = ""; $settings = array( - "asb_settings" => array( - "group" => array( - "name" => 'asb_settings', - "title" => 'Advanced Sidebox', - "description" => $lang->asb_settingsgroup_description, - "disporder" => '101', - "isdefault" => 0 + 'asb_settings' => array( + 'group' => array( + 'name' => 'asb_settings', + 'title' => 'Advanced Sidebox', + 'description' => $lang->asb_settingsgroup_description, + 'disporder' => '101', + 'isdefault' => 0, ), - "settings" => array( - "asb_show_empty_boxes" => array( - "sid" => '0', - "name" => 'asb_show_empty_boxes', - "title" => $lang->asb_show_empty_boxes . ':', - "description" => $db->escape_string($lang->asb_show_empty_boxes_desc), - "optionscode" => 'yesno', - "value" => '1', - "disporder" => '10' + 'settings' => array( + 'asb_show_empty_boxes' => array( + 'sid' => '0', + 'name' => 'asb_show_empty_boxes', + 'title' => $lang->asb_show_empty_boxes.':', + 'description' => $db->escape_string($lang->asb_show_empty_boxes_desc), + 'optionscode' => 'yesno', + 'value' => '1', + 'disporder' => '10', ), - "asb_show_toggle_icons" => array( - "sid" => '0', - "name" => 'asb_show_toggle_icons', - "title" => $lang->asb_show_toggle_icons, - "description" => '', - "optionscode" => 'yesno', - "value" => '0', - "disporder" => '20' + 'asb_show_toggle_icons' => array( + 'sid' => '0', + 'name' => 'asb_show_toggle_icons', + 'title' => $lang->asb_show_toggle_icons, + 'description' => '', + 'optionscode' => 'yesno', + 'value' => '0', + 'disporder' => '20', ), - "asb_show_expanders" => array( - "sid" => '0', - "name" => 'asb_show_expanders', - "title" => $lang->asb_show_expanders, - "description" => '', - "optionscode" => 'yesno', - "value" => '1', - "disporder" => '30' + 'asb_show_expanders' => array( + 'sid' => '0', + 'name' => 'asb_show_expanders', + 'title' => $lang->asb_show_expanders, + 'description' => '', + 'optionscode' => 'yesno', + 'value' => '1', + 'disporder' => '30', ), - "asb_allow_user_disable" => array( - "sid" => '0', - "name" => 'asb_allow_user_disable', - "title" => $lang->asb_allow_user_disable, - "description" => '', - "optionscode" => 'yesno', - "value" => '1', - "disporder" => '40' + 'asb_allow_user_disable' => array( + 'sid' => '0', + 'name' => 'asb_allow_user_disable', + 'title' => $lang->asb_allow_user_disable, + 'description' => '', + 'optionscode' => 'yesno', + 'value' => '1', + 'disporder' => '40', ), - "asb_minify_js" => array( - "sid" => '0', - "name" => 'asb_minify_js', - "title" => $lang->asb_minify_js_title, - "description" => $lang->asb_minify_js_desc, - "optionscode" => 'yesno', - "value" => '1', - "disporder" => '50' + 'asb_minify_js' => array( + 'sid' => '0', + '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" => '0', - "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" => '60' + 'asb_exclude_theme' => array( + 'sid' => '0', + 'name' => 'asb_exclude_theme', + 'title' => $lang->asb_theme_exclude_list.':', + 'description' => $db->escape_string($lang->asb_theme_exclude_list_description.$updateThemeExcludeLink), + 'optionscode' => $db->escape_string(asbBuildThemeExcludeSelect()), + 'value' => '', + 'disporder' => '60', ), - "asb_disable_for_mobile" => array( - "sid" => '0', - "name" => 'asb_disable_for_mobile', - "title" => $lang->asb_disable_for_mobile_title . ':', - "description" => $lang->asb_disable_for_mobile_description, - "optionscode" => 'yesno', - "value" => '0', - "disporder" => '70' + 'asb_disable_for_mobile' => array( + 'sid' => '0', + 'name' => 'asb_disable_for_mobile', + 'title' => $lang->asb_disable_for_mobile_title.':', + 'description' => $lang->asb_disable_for_mobile_description, + 'optionscode' => 'yesno', + 'value' => '0', + 'disporder' => '70', ), ) ) ); $templates = array( - "asb" => array( - "group" => array( - "prefix" => 'asb', - "title" => $lang->asb, + 'asb' => array( + 'group' => array( + 'prefix' => 'asb', + 'title' => $lang->asb, ), - "templates" => array( - "asb_begin" => << array( + 'asb_begin' => << {\$left_content} EOF , - "asb_end" => << << {\$right_content} EOF , - "asb_sidebox_column" => << << {\$sideboxes} {\$content_pad} EOF , - "asb_wrapped_sidebox" => << << @@ -243,16 +243,28 @@
    {\$expaltext}
    +EOF + , + 'asb_ucp_show_sidebox_option' => << + + + + + + + EOF ), ), ); $styleSheets = array( - "folder" => 'asb', - "acp" => array( - "global" => array( - "stylesheet" => << 'asb', + 'acp' => array( + 'global' => array( + 'stylesheet' => << 'asb', - "forum" => array( - "left_arrow.png" => array( - "image" => << 'asb', + 'forum' => array( + 'left_arrow.png' => array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "donate.png" => array( - "image" => << array( + 'donate.png' => array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << array( - "image" => << array( + 'image' => << $info) { - $varName = $info['name'] . 's'; + $varName = $info['name'].'s'; $$varName = 0; if ($age > $info['inSeconds']) { @@ -216,7 +216,7 @@ function asb_forum_age_get_forum_age($args) // remove increments before the selected value that are empty for ($x = 2; $x < 8; $x++) { - $varName = $allInfo[$x - 1]['name'] . 's'; + $varName = $allInfo[$x - 1]['name'].'s'; if ($settings['forum_age_date_format'] >= $x && $$varName == 0) { array_shift($forumAgeArray); @@ -231,7 +231,7 @@ function asb_forum_age_get_forum_age($args) // add "and" if there is more than one entry if (count($forumAgeArray) > 1) { - $forumAgeArray[count($forumAgeArray) - 1] = $lang->asb_forum_age_and . $forumAgeArray[count($forumAgeArray) - 1]; + $forumAgeArray[count($forumAgeArray) - 1] = $lang->asb_forum_age_and.$forumAgeArray[count($forumAgeArray) - 1]; } // compile the time text diff --git a/Upload/inc/plugins/asb/modules/latest_threads.php b/Upload/inc/plugins/asb/modules/latest_threads.php index d2304ab..9ccb01a 100644 --- a/Upload/inc/plugins/asb/modules/latest_threads.php +++ b/Upload/inc/plugins/asb/modules/latest_threads.php @@ -248,7 +248,7 @@ function asb_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 @@ -281,7 +281,7 @@ function asb_latest_threads_get_threadlist($settings, $width) $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 = $new_threads . $important_threads . $unviewwhere . $inactivewhere . 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(); $threadlist = ''; @@ -293,7 +293,7 @@ function asb_latest_threads_get_threadlist($settings, $width) 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'] + LIMIT 0, ".(int) $settings['max_threads'] ); if ($db->num_rows($query) == 0) { @@ -362,18 +362,18 @@ function asb_latest_threads_get_threadlist($settings, $width) } } - $fullSubject = $thread['subject']; + $fullSubject = htmlspecialchars_uni($thread['subject']); $max_len = (int) $settings['max_thread_title_length']; if ($max_len > 0 && my_strlen($thread['subject']) > $max_len) { - $thread['subject'] = my_substr($thread['subject'], 0, $max_len) . $lang->asb_latest_threads_ellipsis; + $thread['subject'] = my_substr($thread['subject'], 0, $max_len).$lang->asb_latest_threads_ellipsis; } $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject'])); $thread['threadlink'] = get_thread_link($thread['tid']); $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, 'lastpost'); - eval("\$last_poster = \"" . $templates->get($lp_template) . "\";"); + eval("\$last_poster = \"{$templates->get($lp_template)}\";"); $gotounread = ''; $last_read = 0; @@ -410,11 +410,11 @@ function asb_latest_threads_get_threadlist($settings, $width) if ($thread['lastpost'] > $last_read && $last_read) { $thread['newpostlink'] = get_thread_link($thread['tid'], 0, 'newpost'); - eval("\$gotounread = \"" . $templates->get("asb_latest_threads_gotounread") . "\";"); + eval("\$gotounread = \"{$templates->get('asb_latest_threads_gotounread')}\";"); $unreadpost = 1; } - eval("\$threadlist .= \"" . $templates->get('asb_latest_threads_thread') . "\";"); + eval("\$threadlist .= \"{$templates->get('asb_latest_threads_thread')}\";"); $altbg = alt_trow(); } diff --git a/Upload/inc/plugins/asb/modules/rand_quote.php b/Upload/inc/plugins/asb/modules/rand_quote.php index 41ac65e..e796eb9 100644 --- a/Upload/inc/plugins/asb/modules/rand_quote.php +++ b/Upload/inc/plugins/asb/modules/rand_quote.php @@ -235,7 +235,7 @@ function asb_rand_quote_get_quote($settings, $width) $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 = $important_threads . $unviewwhere . $inactivewhere . 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 @@ -252,7 +252,7 @@ function asb_rand_quote_get_quote($settings, $width) LIMIT 1;" ); - // if there was 1 . . . + // if there was 1... if ($db->num_rows($post_query) == 0) { return false; } @@ -260,7 +260,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) @@ -289,29 +289,29 @@ function asb_rand_quote_get_quote($settings, $width) if ($settings['max_length'] && strlen($new_message) > $settings['max_length']) { - $new_message = substr($new_message, 0, $settings['max_length']) . ' . . .'; + $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 $plain_text_username = htmlspecialchars_uni($rand_post['username']); $username = format_name($plain_text_username, $rand_post['usergroup'], $rand_post['displaygroup']); $author_link = get_profile_link($rand_post['uid']); - $post_link = get_post_link($rand_post['pid'], $rand_post['tid']) . '#pid' . $rand_post['pid']; + $post_link = get_post_link($rand_post['pid'], $rand_post['tid']).'#pid'.$rand_post['pid']; $thread_link = get_thread_link($rand_post['tid']); // allow smilies, but kill $parser_options = array('allow_smilies' => 1); - $new_message = str_replace(array('
    ', '/me'), array('', " * {$plain_text_username}"), $parser->parse_message($new_message . ' ', $parser_options)); + $new_message = str_replace(array('
    ', '/me'), array('', " * {$plain_text_username}"), $parser->parse_message($new_message.' ', $parser_options)); $avatar_info = format_avatar($rand_post['avatar']); $avatar_filename = $avatar_info['image']; $avatar_alt = $lang->sprintf($lang->asb_random_quote_users_profile, $plain_text_username); - eval("\$read_more = \"" . $templates->get('asb_rand_quote_read_more') . "\";"); + eval("\$read_more = \"{$templates->get('asb_rand_quote_read_more')}\";"); 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:') { @@ -325,7 +325,7 @@ function asb_rand_quote_get_quote($settings, $width) EOF; // eval() the template - eval("\$this_quote = \"" . $templates->get("asb_rand_quote_sidebox") . "\";"); + eval("\$this_quote = \"{$templates->get('asb_rand_quote_sidebox')}\";"); return $this_quote; } diff --git a/Upload/inc/plugins/asb/modules/recent_posts.php b/Upload/inc/plugins/asb/modules/recent_posts.php index f1f898a..5064ec5 100644 --- a/Upload/inc/plugins/asb/modules/recent_posts.php +++ b/Upload/inc/plugins/asb/modules/recent_posts.php @@ -202,7 +202,7 @@ function recent_posts_get_postlist($settings) $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 = $important_threads . $unviewwhere . $inactivewhere . 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; @@ -221,7 +221,7 @@ function recent_posts_get_postlist($settings) ORDER BY p.dateline DESC LIMIT - 0, " . (int) $settings['max_posts'] + 0, ".(int) $settings['max_posts'] ); if ($db->num_rows($query) == 0) { @@ -230,7 +230,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(); @@ -264,11 +264,11 @@ function recent_posts_get_postlist($settings) $max_len = (int) $settings['max_thread_title_length']; if ($max_len > 0 && my_strlen($post['subject']) > $max_len) { - $post['subject'] = my_substr($post['subject'], 0, $max_len) . $lang->asb_recent_posts_title_ellipsis; + $post['subject'] = my_substr($post['subject'], 0, $max_len).$lang->asb_recent_posts_title_ellipsis; } $post['subject'] = htmlspecialchars_uni($parser->parse_badwords($post['subject'])); - $post['link'] = get_post_link($post['pid'], $post['tid']) . "#pid{$post['pid']}"; + $post['link'] = get_post_link($post['pid'], $post['tid'])."#pid{$post['pid']}"; // we just need the text and smilies (we'll parse them after we check length) $pattern = "|[[\/\!]*?[^\[\]]*?]|si"; @@ -276,10 +276,10 @@ function recent_posts_get_postlist($settings) if ($settings['max_length'] && strlen($post_excerpt) > $settings['max_length']) { - $post_excerpt = my_substr($post_excerpt, 0, $settings['max_length']) . $lang->asb_recent_posts_ellipsis; + $post_excerpt = my_substr($post_excerpt, 0, $settings['max_length']).$lang->asb_recent_posts_ellipsis; } - eval("\$postlist .= \"" . $templates->get("asb_recent_posts_post") . "\";"); + eval("\$postlist .= \"{$templates->get('asb_recent_posts_post')}\";"); $altbg = alt_trow(); } return $postlist; diff --git a/Upload/inc/plugins/asb/modules/search_box.php b/Upload/inc/plugins/asb/modules/search_box.php index 4fc81c3..30ebc70 100644 --- a/Upload/inc/plugins/asb/modules/search_box.php +++ b/Upload/inc/plugins/asb/modules/search_box.php @@ -86,7 +86,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 index 628e66f..4b98e5e 100644 --- a/Upload/inc/plugins/asb/modules/slideshow.php +++ b/Upload/inc/plugins/asb/modules/slideshow.php @@ -178,7 +178,7 @@ function asb_slideshow_build_template($args) } if ($settings['footer_text'] && $settings['footer_url']) { - eval ("\$footer = \"" . $templates->get('asb_slideshow_footer') . "\";"); + eval ("\$footer = \"{$templates->get('asb_slideshow_footer')}\";"); } $max_width = (int) $settings['max_width']; @@ -186,7 +186,7 @@ function asb_slideshow_build_template($args) $maintain_height = (int) $settings['maintain_height']; $width = $width * .9; - eval("\$\$template_var = \"" . $templates->get('asb_slideshow') . "\";"); + eval("\$\$template_var = \"{$templates->get('asb_slideshow')}\";"); 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 d0aa3b6..6d378ce 100644 --- a/Upload/inc/plugins/asb/modules/staff_online_box.php +++ b/Upload/inc/plugins/asb/modules/staff_online_box.php @@ -61,7 +61,7 @@ function asb_staff_online_box_info() 'description' => $lang->asb_xmlhttp_on_description, 'optionscode' => 'text', 'value' => '0', - ) + ), ), 'discarded_templates' => array( 'asb_staff_online', @@ -186,7 +186,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)); - // if there were no groups . . . + // if there were no groups... if (!$groups_in) { // there is nothing to show return false; @@ -210,7 +210,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) // loop through our users while ($user = $db->fetch_array($query)) { - // if displaygroup is not 0 (display primary group) . . . + // if displaygroup is not 0, display primary group if ($user['displaygroup'] != 0) { // then use this group $group = $user['displaygroup']; @@ -231,7 +231,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) // loop through each user group foreach ($usergroups as $usergroup) { - // if there are no users or we have reached our limit . . . + // if there are no users or we have reached our limit... if (!isset($usergroup['user_list']) || $counter > $max_rows) { // skip an iteration continue; @@ -250,7 +250,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) // prepare the info // alt and title for image are the same - $staff_avatar_alt = $staff_avatar_title = $user['username'] . '\'s profile'; + $staff_avatar_alt = $staff_avatar_title = "{$user['username']}'s profile"; // if the user has an avatar then display it, otherwise force the default avatar. $avatar_info = format_avatar($user['avatar']); @@ -269,7 +269,7 @@ function asb_staff_online_box_get_online_staff($settings, $width) // badge alt and title are the same $staff_badge_alt = $staff_badge_title = $usergroup['usertitle']; - // if the user's group has a badge image . . . + // if the user's group has a badge image... $staff_badge = $staff_badge_alt; if ($usergroup['image']) { // store it (if nothing is store alt property will display group default usertitle) @@ -287,11 +287,11 @@ function asb_staff_online_box_get_online_staff($settings, $width) ++$counter; // add this row to the table - eval("\$online_staff .= \"" . $templates->get("asb_staff_online_bit") . "\";"); + eval("\$online_staff .= \"{$templates->get("asb_staff_online_bit")}\";"); } } - // if there were staff members online . . . + // if there were staff members online... if ($online_staff) { // show them return $online_staff; diff --git a/Upload/inc/plugins/asb/modules/statistics.php b/Upload/inc/plugins/asb/modules/statistics.php index ba259fa..22817d2 100644 --- a/Upload/inc/plugins/asb/modules/statistics.php +++ b/Upload/inc/plugins/asb/modules/statistics.php @@ -95,7 +95,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 index dc4486e..0f204d8 100644 --- a/Upload/inc/plugins/asb/modules/top_poster.php +++ b/Upload/inc/plugins/asb/modules/top_poster.php @@ -227,7 +227,7 @@ function asb_top_poster_build_template($args) $thread_where = " AND p.tid='{$tid}'"; $threadQuery = $db->simple_select('threads', 'subject', "tid='{$tid}'"); if ($db->num_rows($threadQuery) > 0) { - require_once MYBB_ROOT . 'inc/class_parser.php'; + require_once MYBB_ROOT.'inc/class_parser.php'; $parser = new postParser; $threadTitle = $db->fetch_field($threadQuery, 'subject'); @@ -303,7 +303,7 @@ function asb_top_poster_build_template($args) $top_poster_posts = $lang->asb_top_poster_no_posts; $top_poster_text = $lang->asb_top_poster_no_top_poster; $top_poster_avatar = ''; - eval("\$\$template_var = \"" . $templates->get('asb_top_posters_single') . "\";"); + eval("\$\$template_var = \"{$templates->get('asb_top_posters_single')}\";"); return false; } @@ -357,29 +357,29 @@ function asb_top_poster_build_template($args) $avatar_width = (int) $settings['avatar_size']; } - eval("\$top_poster_avatar = \"" . $templates->get('asb_top_poster_avatar') . "\";"); + eval("\$top_poster_avatar = \"{$templates->get('asb_top_poster_avatar')}\";"); - eval("\$\$template_var = \"" . $templates->get('asb_top_posters_single') . "\";"); + eval("\$\$template_var = \"{$templates->get('asb_top_posters_single')}\";"); } else { - $top_poster_description = $lang->sprintf($lang->asb_top_poster_description, $top_poster_timeframe_prelude) . $extraCongrats; + $top_poster_description = $lang->sprintf($lang->asb_top_poster_description, $top_poster_timeframe_prelude).$extraCongrats; if ($threadsOnly) { - $top_poster_description = $lang->sprintf($lang->asb_top_poster_description_threads, $top_poster_timeframe_prelude) . $extraCongrats; + $top_poster_description = $lang->sprintf($lang->asb_top_poster_description_threads, $top_poster_timeframe_prelude).$extraCongrats; } - $top_poster_text = $top_poster . '
    ' . $top_poster_posts; + $top_poster_text = $top_poster.'
    '.$top_poster_posts; $avatar_width = (int) $width * .2; if ((int) $settings['avatar_size']) { $avatar_width = (int) $settings['avatar_size']; } - eval("\$top_poster_avatar = \"" . $templates->get('asb_top_poster_avatar') . "\";"); + eval("\$top_poster_avatar = \"{$templates->get('asb_top_poster_avatar')}\";"); - eval("\$top_posters .= \"" . $templates->get('asb_top_poster') . "\";"); + eval("\$top_posters .= \"{$templates->get('asb_top_poster')}\";"); } $altbg = alt_trow(); } if ($db->num_rows($query) > 1) { - eval("\$\$template_var .= \"" . $templates->get('asb_top_posters_multiple') . "\";"); + eval("\$\$template_var .= \"{$templates->get('asb_top_posters_multiple')}\";"); } return true; } diff --git a/Upload/inc/plugins/asb/modules/welcome_box.php b/Upload/inc/plugins/asb/modules/welcome_box.php index c4fd4ec..8d5ef92 100644 --- a/Upload/inc/plugins/asb/modules/welcome_box.php +++ b/Upload/inc/plugins/asb/modules/welcome_box.php @@ -92,7 +92,7 @@ function asb_welcome_box_build_template($args) if ($mybb->user['uid'] != 0) { // Get number of new posts, threads, announcements - $query = $db->simple_select('posts', 'COUNT(pid) AS newposts', "visible=1 AND dateline > '{$mybb->user['lastvisit']}' $unviewwhere"); + $query = $db->simple_select('posts', 'COUNT(pid) AS newposts', "visible=1 AND dateline > '{$mybb->user['lastvisit']}' {$unviewwhere}"); $newposts = $db->fetch_field($query, 'newposts'); if ($newposts) { // If there aren't any new posts, there is no point in wasting two more queries @@ -149,9 +149,9 @@ function asb_welcome_box_build_template($args) {$mybb->user['username']}'s profile  EOF; - eval("\$welcometext = \"" . $templates->get("asb_welcome_membertext") . "\";"); + eval("\$welcometext = \"{$templates->get('asb_welcome_membertext')}\";"); } else { - $lang->asb_welcome_guest_welcome_registration = $lang->sprintf($lang->asb_welcome_guest_welcome_registration, $mybb->settings['bburl'] . '/member.php?action=register'); + $lang->asb_welcome_guest_welcome_registration = $lang->sprintf($lang->asb_welcome_guest_welcome_registration, $mybb->settings['bburl'].'/member.php?action=register'); $mybb->user['username'] = $lang->guest; switch ($mybb->settings['username_method']) { case 0: @@ -167,11 +167,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 0367e3c..9759eb6 100644 --- a/Upload/inc/plugins/asb/modules/whosonline.php +++ b/Upload/inc/plugins/asb/modules/whosonline.php @@ -68,7 +68,7 @@ function asb_whosonline_info() 'description' => $lang->asb_xmlhttp_on_description, 'optionscode' => 'text', 'value' => '0', - ) + ), ), 'templates' => array( array( @@ -130,7 +130,7 @@ function asb_whosonline_build_template($args) // get the online members $all_onlinemembers = asb_whosonline_get_online_members($settings, $width); - // if there are members online . . . + // if there are members online... if ($all_onlinemembers) { // set out template variable to the returned member list and return true $$template_var = $all_onlinemembers; @@ -263,15 +263,15 @@ function asb_whosonline_get_online_members($settings, $width) $avatar_count) { // check to see if we've already handled this, if so, do nothing if (!$enough_already) { - // . . . if not, set a flag + // ...if not, set a flag $enough_already = true; - // . . . and insert link to the WOL full list - eval("\$onlinemembers .= \"" . $templates->get('asb_whosonline_memberbit_see_all', 1, 0) . "\";"); + // ...and insert link to the WOL full list + eval("\$onlinemembers .= \"{$templates->get('asb_whosonline_memberbit_see_all', 1, 0)}\";"); } - // . . . otherwise, add it to the list + // ...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) { @@ -282,8 +282,8 @@ 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) . "\";"); - $sep = $lang->comma . ' '; + eval("\$onlinemembers .= \"{$templates->get('asb_whosonline_memberbit_name', 1, 0)}\";"); + $sep = $lang->comma.' '; } } else { --$membercount; @@ -292,7 +292,7 @@ function asb_whosonline_get_online_members($settings, $width) } if (!$settings['show_avatars']) { - $onlinemembers = '' . $onlinemembers . ''; + $onlinemembers = ''.$onlinemembers.''; } $onlinecount = $membercount + $guestcount + $botcount; @@ -327,7 +327,7 @@ function asb_whosonline_get_online_members($settings, $width) $lang->asb_wol_online_counts = $lang->sprintf($lang->asb_wol_online_counts, $membercount, $guestcount); if ($membercount) { - eval("\$onlinemembers = \"" . $templates->get('asb_whosonline') . "\";"); + eval("\$onlinemembers = \"{$templates->get('asb_whosonline')}\";"); return $onlinemembers; } else { return false; diff --git a/Upload/inc/plugins/asb/upgrade.php b/Upload/inc/plugins/asb/upgrade.php index fc66c81..3b370d6 100644 --- a/Upload/inc/plugins/asb/upgrade.php +++ b/Upload/inc/plugins/asb/upgrade.php @@ -18,7 +18,7 @@ /* < 2.1 */ if (version_compare($asbOldVersion, '2.1', '<')) { - $sideboxes = asb_get_all_sideboxes(); + $sideboxes = asbGetAllSideBoxes(); foreach ($sideboxes as $sidebox) { $settings = array(); foreach ((array) $sidebox->get('settings') as $name => $setting) { @@ -29,16 +29,16 @@ } for ($x = 1; $x < 4; $x++) { - $module_name = 'example'; + $moduleName = 'example'; if ($x != 1) { - $module_name .= $x; + $moduleName .= $x; } - $module = new SideboxExternalModule($module_name); + $module = new SideboxExternalModule($moduleName); $module->remove(); } - asb_cache_has_changed(); + asbCacheHasChanged(); $removedForumFiles = array( 'jscripts/asb.js', @@ -128,27 +128,27 @@ if (!empty($removedForumFiles)) { foreach ($removedForumFiles as $file) { - @unlink(MYBB_ROOT . $file); + @unlink(MYBB_ROOT.$file); } } if (!empty($removedForumFolders)) { foreach ($removedForumFolders as $folder) { - @my_rmdir_recursive(MYBB_ROOT . $folder); - @rmdir(MYBB_ROOT . $folder); + @my_rmdir_recursive(MYBB_ROOT.$folder); + @rmdir(MYBB_ROOT.$folder); } } if (!empty($removedAdminFiles)) { foreach ($removedAdminFiles as $file) { - @unlink(MYBB_ADMIN_DIR . $file); + @unlink(MYBB_ADMIN_DIR.$file); } } if (!empty($removedAdminFolders)) { foreach ($removedAdminFolders as $folder) { - @my_rmdir_recursive(MYBB_ADMIN_DIR . $folder); - @rmdir(MYBB_ADMIN_DIR . $folder); + @my_rmdir_recursive(MYBB_ADMIN_DIR.$folder); + @rmdir(MYBB_ADMIN_DIR.$folder); } }