Exemplo n.º 1
0
 /**
  * Standard modular run function for newsletter hooks.
  *
  * @return ?array				Tuple of result details: HTML list of all types that can be choosed, title for selection list (NULL: disabled)
  */
 function choose_categories()
 {
     if (!addon_installed('galleries')) {
         return NULL;
     }
     require_lang('galleries');
     require_code('galleries');
     return array(nice_get_gallery_tree(NULL, NULL, false, false, true), do_lang('GALLERIES'));
 }
Exemplo n.º 2
0
 /**
  * Standard modular simple function for ajax-tree hooks. Returns a normal <select> style <option>-list, for fallback purposes
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root) - not always supported
  * @param  array			Options being passed through
  * @param  ?ID_TEXT		The ID to select by default (NULL: none)
  * @return tempcode		The nice list
  */
 function simple($id, $options, $it = NULL)
 {
     unset($id);
     $must_accept_images = array_key_exists('must_accept_images', $options) ? $options['must_accept_images'] : false;
     $must_accept_videos = array_key_exists('must_accept_videos', $options) ? $options['must_accept_videos'] : false;
     $filter = array_key_exists('filter', $options) ? $options['filter'] : NULL;
     $purity = array_key_exists('purity', $options) ? $options['purity'] : false;
     $member_id = array_key_exists('member_id', $options) ? $options['member_id'] : NULL;
     $compound_list = array_key_exists('compound_list', $options) ? $options['compound_list'] : false;
     $addable_filter = array_key_exists('addable_filter', $options) ? $options['addable_filter'] : false;
     require_code('galleries');
     return nice_get_gallery_tree($it, $filter, $must_accept_images, $must_accept_videos, $purity, $compound_list, $member_id, $addable_filter);
 }
Exemplo n.º 3
0
 /**
  * The UI to import into a gallery.
  *
  * @return tempcode		The UI
  */
 function _gimp()
 {
     $cat = get_param('name', 'root');
     check_specific_permission('mass_import');
     if (substr($cat, 0, 7) != 'member_') {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $cat));
         if (is_null($test)) {
             warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
         }
     }
     $title = get_page_title('GALLERY_IMPORT');
     require_code('form_templates');
     require_lang('trackbacks');
     // To choose to batch import from an attached tar or zip file (zip file only supported if zip module running on php install)
     $post_url = build_url(array('page' => '_SELF', 'type' => '__gimp', 'cat' => $cat, 'uploading' => 1, 'redirect' => get_param('redirect', NULL)), '_SELF');
     $fields = new ocp_tempcode();
     $supported = 'tar';
     if (function_exists('zip_open') || get_option('unzip_cmd') != '') {
         $supported .= ', zip';
     }
     $fields->attach(form_input_upload_multi(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_ARCHIVE_MEDIA', escape_html($supported), escape_html(str_replace(',', ', ', get_option('valid_images') . ',' . get_allowed_video_file_types()))), 'file', true, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',' . $supported)));
     $hidden = new ocp_tempcode();
     handle_max_file_size($hidden);
     if (get_option('is_on_gd') == '1') {
         if ($this->has_at_least_one_watermark($cat)) {
             $fields->attach(form_input_tick(do_lang_tempcode('WATERMARK'), do_lang_tempcode('DESCRIPTION_WATERMARK'), 'watermark', true));
         }
     }
     // Feedback
     require_code('feedback2');
     $fields->attach(feedback_fields(true, true, true, false, ''));
     // Max upload limit
     require_code('files2');
     $max = floatval(get_max_file_size()) / floatval(1024 * 1024);
     if ($max < 30.0) {
         $config_url = get_upload_limit_config_url();
         $text = paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url)));
     } else {
         $text = new ocp_tempcode();
     }
     // Show form
     $hidden->attach(form_input_hidden('test', '1'));
     $form = do_template('FORM', array('_GUID' => '05de2bc134ed0b1ab703ac8bfbfabce4', 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('BATCH_IMPORT_ARCHIVE_CONTENTS'), 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden));
     // Orphaned upload form
     // To choose to batch import what already exists in gallery directory, but is orphaned
     $orphaned_content = new ocp_tempcode();
     if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)') + $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)') < 4000) {
         require_code('images');
         $there = array();
         $_dir = opendir(get_custom_file_base() . '/uploads/galleries/');
         while (false !== ($file = readdir($_dir))) {
             if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $file) && (is_image($file) || is_video($file))) {
                 $there[$file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $file);
             }
         }
         closedir($_dir);
         $_dir = @opendir(get_custom_file_base() . '/uploads/galleries/' . filter_naughty($cat));
         if ($_dir !== false) {
             while (false !== ($file = readdir($_dir))) {
                 if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file) && (is_image($file) || is_video($file))) {
                     $there[$cat . '/' . $file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file);
                 }
             }
             closedir($_dir);
         }
         if (count($there) != 0) {
             asort($there);
             $test1 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('images', array('url')));
             $test2 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('videos', array('url')));
             arsort($there);
             $temp_keys = array_keys($there);
             $last_time = $there[$temp_keys[0]];
             foreach ($there as $file => $time) {
                 if (!in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test1) && !in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test2)) {
                     $orphaned_content->attach(form_input_list_entry($file, $time >= $last_time - 60 * 60 * 3 || strpos($file, '/') !== false, $file));
                 }
             }
         }
         $add_url = build_url(array('page' => '_SELF', 'type' => 'ss'), '_SELF');
         if (!$orphaned_content->is_empty()) {
             $fields_2 = new ocp_tempcode();
             $hidden_2 = new ocp_tempcode();
             if (get_param_integer('keep_de_orphan', 0) == 1) {
                 $cats = nice_get_gallery_tree($cat, NULL, false, false, false, false, NULL, true);
                 $fields_2->attach(form_input_list(do_lang_tempcode('GALLERY'), '', 'cat', $cats));
             } else {
                 $hidden_2->attach(form_input_hidden('cat', $cat));
             }
             $fields_2->attach(form_input_multi_list(do_lang_tempcode('ENTRIES'), '', 'files', $orphaned_content));
             if ($this->has_at_least_one_watermark($cat)) {
                 $fields_2->attach(form_input_various_ticks(array(array(do_lang_tempcode('WATERMARK'), 'watermark', true, ''), array(do_lang_tempcode('ALLOW_RATING'), 'allow_rating', true, ''), array(do_lang_tempcode('ALLOW_COMMENTS'), 'allow_comments', true, ''), array(do_lang_tempcode('ALLOW_REVIEWS'), 'allow_reviews', false, ''), array(do_lang_tempcode('ALLOW_TRACKBACKS'), 'allow_trackbacks', true, '')), '', NULL, do_lang_tempcode('OPTIONS')));
             }
             $radios = new ocp_tempcode();
             $radios->attach(form_input_radio_entry('type', 'sa', true, do_lang_tempcode('ADD_GALLERY_SELECTION')));
             $radios->attach(form_input_radio_entry('type', 'sd', false, do_lang_tempcode('DELETE_GALLERY_SELECTION')));
             $fields_2->attach(form_input_radio(do_lang_tempcode('ACTION'), '', 'type', $radios, true));
             // Feedback
             require_code('feedback2');
             $fields_2->attach(feedback_fields(true, true, true, false, ''));
             $form2 = do_template('FORM', array('SECONDARY_FORM' => true, 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields_2, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'URL' => $add_url, 'TEXT' => '', 'HIDDEN' => $hidden_2));
         } else {
             $form2 = new ocp_tempcode();
         }
     } else {
         $form2 = new ocp_tempcode();
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_GALLERIES')), array('_SELF:_SELF:gimp', do_lang_tempcode('GALLERY'))));
     breadcrumb_set_self(do_lang_tempcode('UPLOAD'));
     return do_template('GALLERY_IMPORT_SCREEN', array('_GUID' => '607c819ff751268294e5e590a0d41533', 'TITLE' => $title, 'FORM2' => $form2, 'FORM' => $form));
 }
Exemplo n.º 4
0
/**
 * Shows an HTML page for making block Comcode.
 */
function block_helper_script()
{
    require_lang('comcode');
    require_lang('blocks');
    require_code('zones2');
    require_code('zones3');
    check_specific_permission('comcode_dangerous');
    $title = get_page_title('BLOCK_HELPER');
    require_code('form_templates');
    require_all_lang();
    $type_wanted = get_param('block_type', 'main');
    $type = get_param('type', 'step1');
    $content = new ocp_tempcode();
    if ($type == 'step1') {
        // Find what addons all our block files are in, and icons if possible
        $hooks = find_all_hooks('systems', 'addon_registry');
        $hook_keys = array_keys($hooks);
        $hook_files = array();
        foreach ($hook_keys as $hook) {
            $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            if (!file_exists($path)) {
                $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            }
            $hook_files[$hook] = file_get_contents($path);
        }
        unset($hook_keys);
        $addon_icons = array();
        $addons_blocks = array();
        foreach ($hook_files as $addon_name => $hook_file) {
            $matches = array();
            if (preg_match('#function get_file_list\\(\\)\\s*\\{([^\\}]*)\\}#', $hook_file, $matches) != 0) {
                if (!defined('HIPHOP_PHP')) {
                    $addon_files = eval($matches[1]);
                } else {
                    require_code('hooks/systems/addon_registry/' . $addon_name);
                    $hook_ob = object_factory('Hook_addon_registry_' . $addon_name);
                    $addon_files = $hook_ob->get_file_list();
                }
                foreach ($addon_files as $file) {
                    if (substr($file, 0, 31) == 'themes/default/images/bigicons/' && !array_key_exists($addon_name, $addon_icons)) {
                        $addon_icons[$addon_name] = find_theme_image('bigicons/' . basename($file, '.png'), false, true);
                    }
                    if (substr($file, 0, 21) == 'sources_custom/blocks/' || substr($file, 0, 15) == 'sources/blocks/') {
                        if ($addon_name == 'staff_messaging') {
                            $addon_name = 'core_feedback_features';
                        }
                        $addons_blocks[basename($file, '.php')] = $addon_name;
                    }
                }
            }
        }
        // Find where blocks have been used
        $block_usage = array();
        $zones = find_all_zones(false, true);
        foreach ($zones as $_zone) {
            $zone = $_zone[0];
            $pages = find_all_pages_wrap($zone, true);
            foreach ($pages as $filename => $type) {
                if (substr(strtolower($filename), -4) == '.txt') {
                    $matches = array();
                    $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename));
                    //$fallback=get_file_base().'/'.(($zone=='')?'':($zone.'/')).'pages/comcode/'.fallback_lang().'/'.$filename;
                    //if (file_exists($fallback)) $contents.=file_get_contents($fallback);
                    $num_matches = preg_match_all('#\\[block[^\\]]*\\](.*)\\[/block\\]#U', $contents, $matches);
                    for ($i = 0; $i < $num_matches; $i++) {
                        $block_used = $matches[1][$i];
                        if (!array_key_exists($block_used, $block_usage)) {
                            $block_usage[$block_used] = array();
                        }
                        $block_usage[$block_used][] = $zone . ':' . basename($filename, '.txt');
                    }
                }
            }
        }
        // Show block list
        $links = new ocp_tempcode();
        $blocks = find_all_blocks();
        $dh = @opendir(get_file_base() . '/sources_custom/miniblocks');
        if ($dh !== false) {
            while (($file = readdir($dh)) !== false) {
                if (substr($file, -4) == '.php' && preg_match('#^[\\w\\-]*$#', substr($file, 0, strlen($file) - 4)) != 0) {
                    $blocks[substr($file, 0, strlen($file) - 4)] = 'sources_custom';
                }
            }
            closedir($dh);
        }
        $block_types = array();
        $block_types_icon = array();
        $keep = symbol_tempcode('KEEP');
        foreach (array_keys($blocks) as $block) {
            if (array_key_exists($block, $addons_blocks)) {
                $addon_name = $addons_blocks[$block];
                $addon_icon = array_key_exists($addon_name, $addon_icons) ? $addon_icons[$addon_name] : NULL;
                $addon_name = preg_replace('#^core\\_#', '', $addon_name);
            } else {
                $addon_name = NULL;
                $addon_icon = NULL;
            }
            $this_block_type = is_null($addon_name) || strpos($addon_name, 'block') !== false || $addon_name == 'core' ? substr($block, 0, strpos($block, '_') === false ? strlen($block) : strpos($block, '_')) : $addon_name;
            if (!array_key_exists($this_block_type, $block_types)) {
                $block_types[$this_block_type] = new ocp_tempcode();
            }
            if (!is_null($addon_icon)) {
                $block_types_icon[$this_block_type] = $addon_icon;
            }
            $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
            $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
            if (is_null($block_description)) {
                $block_description = '';
            }
            if (is_null($block_use)) {
                $block_use = '';
            }
            $descriptiont = $block_description == '' && $block_use == '' ? new ocp_tempcode() : do_lang_tempcode('BLOCK_HELPER_1X', $block_description, $block_use);
            $url = find_script('block_helper') . '?type=step2&block=' . urlencode($block) . '&field_name=' . get_param('field_name') . $keep->evaluate();
            if (get_param('utheme', '') != '') {
                $url .= '&utheme=' . get_param('utheme');
            }
            $url .= '&block_type=' . $type_wanted;
            $link_caption = do_lang_tempcode('NICE_BLOCK_NAME', escape_html(cleanup_block_name($block)), $block);
            $usage = array_key_exists($block, $block_usage) ? $block_usage[$block] : array();
            $block_types[$this_block_type]->attach(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $descriptiont, 'URL' => $url, 'LINK_CAPTION' => $link_caption)));
        }
        /*if (array_key_exists($type_wanted,$block_types)) We don't do this now, as we structure by addon name
        		{
        			$x=$block_types[$type_wanted];
        			unset($block_types[$type_wanted]);
        			$block_types=array_merge(array($type_wanted=>$x),$block_types);
        		}*/
        ksort($block_types);
        // We sort now instead
        $move_after = $block_types['adminzone_frontpage'];
        unset($block_types['adminzone_frontpage']);
        $block_types['adminzone_frontpage'] = $move_after;
        foreach ($block_types as $block_type => $_links) {
            switch ($block_type) {
                case 'side':
                case 'main':
                case 'bottom':
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_' . $block_type);
                    $img = NULL;
                    break;
                default:
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_ADDON', escape_html(cleanup_block_name($block_type)));
                    $img = array_key_exists($block_type, $block_types_icon) ? $block_types_icon[$block_type] : NULL;
                    break;
            }
            $links->attach(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => $img, 'TITLE' => $type_title, 'LINKS' => $_links)));
        }
        $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $links));
    } elseif ($type == 'step2') {
        require_code('comcode_text');
        $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), 'block');
        $block = trim(get_param('block'));
        $title = get_page_title('_BLOCK_HELPER', true, array(escape_html($block)));
        $fields = new ocp_tempcode();
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (!isset($defaults['cache'])) {
            $defaults['cache'] = block_cache_default($block);
        }
        if (is_null($parameters)) {
            $parameters = array();
        }
        $advanced_ind = do_lang('BLOCK_IND_ADVANCED');
        $param_classes = array('normal' => array(), 'advanced' => array());
        foreach ($parameters as $parameter) {
            $param_class = 'normal';
            if ($parameter == 'cache' || $parameter == 'quick_cache' || $parameter == 'failsafe' || strpos(do_lang('BLOCK_' . $block . '_PARAM_' . $parameter), $advanced_ind) !== false) {
                $param_class = 'advanced';
            }
            $param_classes[$param_class][] = $parameter;
        }
        foreach ($param_classes as $param_class => $parameters) {
            if (count($parameters) == 0) {
                if ($param_class == 'normal') {
                    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS'), 'HELP' => protect_from_escaping(paragraph(do_lang_tempcode('BLOCK_HELPER_NO_PARAMETERS'), '', 'nothing_here')))));
                }
                continue;
            }
            if ($param_class == 'advanced') {
                $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
            }
            foreach ($parameters as $parameter) {
                $matches = array();
                switch ($parameter) {
                    case 'quick_cache':
                    case 'cache':
                    case 'failsafe':
                        $description = do_lang('BLOCK_PARAM_' . $parameter);
                        break;
                    default:
                        $description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter);
                        break;
                }
                $description = str_replace(do_lang('BLOCK_IND_STRIPPABLE_1'), '', $description);
                $description = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $description));
                // Work out default value for field
                $default = '';
                if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $description, $matches) != 0) {
                    $default = $matches[1];
                    $has_default = true;
                    $description = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $description);
                } else {
                    $has_default = false;
                }
                if (isset($defaults[$parameter])) {
                    $default = $defaults[$parameter];
                    $has_default = true;
                }
                // Show field
                if ($block . ':' . $parameter == 'side_stored_menu:type') {
                    $matches = array();
                    $dh = opendir(get_file_base() . '/themes/default/templates/');
                    $options = array();
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom/');
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0 && !file_exists(get_file_base() . '/themes/default/templates/' . $file)) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    sort($options);
                    $list = new ocp_tempcode();
                    foreach ($options as $option) {
                        $list->attach(form_input_list_entry($option, $has_default && $option == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_stored_menu:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu');
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry($row['i_menu'], $has_default && $row['i_menu'] == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_shoutbox:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'room_name'), array('is_im' => 0), '', 100);
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, $row['room_name']));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_poll:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('poll', array('id', 'question'), NULL, 'ORDER BY id DESC', 100);
                    $list->attach(form_input_list_entry('', false, do_lang('NA')));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['question'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_awards:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('id', 'a_title'));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['a_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'zone' || $parameter == 'param' && $block == 'main_as_zone_access') {
                    $list = new ocp_tempcode();
                    $list->attach(form_input_list_entry('_SEARCH', $default == ''));
                    $list->attach(nice_get_zones($default == '' ? NULL : $default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (($parameter == 'forum' || $parameter == 'param' && in_array($block, array('main_forum_topics'))) && get_forum_type() == 'ocf') {
                    require_code('ocf_forums');
                    require_code('ocf_forums2');
                    if (!addon_installed('ocf_forum')) {
                        warn_exit(do_lang_tempcode('NO_FORUM_INSTALLED'));
                    }
                    $list = ocf_get_forum_tree_secure(NULL, NULL, true, explode(',', $default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'param' && in_array($block, array('side_root_galleries', 'main_gallery_tease', 'main_gallery_embed', 'main_image_fader'))) {
                    require_code('galleries');
                    $list = nice_get_gallery_tree($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_download_category'))) {
                    require_code('downloads');
                    $list = nice_get_download_category_tree($default == '' ? NULL : intval($default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_contact_catalogues')) || $parameter == 'catalogue' && in_array($block, array('main_recent_cc_entries'))) {
                    require_code('catalogues');
                    $list = nice_get_catalogues($default, false);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_cc_embed')) && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)') < 500) {
                    $list = new ocp_tempcode();
                    $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'c_name'), NULL, 'ORDER BY c_name,id');
                    $last_cat = mixed();
                    foreach ($categories as $cat) {
                        if (is_null($last_cat) || $cat['c_name'] != $last_cat) {
                            $list->attach(form_input_list_entry($cat['c_name'], $has_default && $cat['c_name'] == $default, $cat['c_name'], false, true));
                            $last_cat = $cat['c_name'];
                        }
                        $list->attach(form_input_list_entry(strval($cat['id']), $has_default && strval($cat['id']) == $default, get_translated_text($cat['cc_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_banner_wave', 'main_topsites'))) {
                    require_code('banners');
                    $list = nice_get_banner_types($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_newsletter_signup'))) {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title'));
                    foreach ($rows as $newsletter) {
                        $list->attach(form_input_list_entry(strval($newsletter['id']), $has_default && strval($newsletter['id']) == $default, get_translated_text($newsletter['title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'filter' && in_array($block, array('bottom_news', 'main_news', 'side_news', 'side_news_archive'))) {
                    require_code('news');
                    $list = nice_get_news_categories($default == '' ? -1 : intval($default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'font') {
                    $fonts = array();
                    $dh = opendir(get_file_base() . '/data/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/data_custom/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $fonts = array_unique($fonts);
                    sort($fonts);
                    $list = new ocp_tempcode();
                    foreach ($fonts as $font) {
                        $list->attach(form_input_list_entry($font, $font == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#' . do_lang('BLOCK_IND_EITHER') . ' (.+)#i', $description, $matches) != 0) {
                    $description = preg_replace('# \\(' . do_lang('BLOCK_IND_EITHER') . '.*\\)#U', '', $description);
                    $list = new ocp_tempcode();
                    $matches2 = array();
                    $num_matches = preg_match_all('#\'([^\']*)\'="([^"]*)"#', $matches[1], $matches2);
                    if ($num_matches != 0) {
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default, $matches2[2][$i]));
                        }
                    } else {
                        $num_matches = preg_match_all('#\'([^\']*)\'#', $matches[1], $matches2);
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default));
                        }
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', $description, $matches) != 0) {
                    $description = preg_replace('#\\s*\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', '', $description);
                    $list = new ocp_tempcode();
                    $hooks = find_all_hooks($matches[1], $matches[2]);
                    ksort($hooks);
                    if ($default == '' && $has_default) {
                        $list->attach(form_input_list_entry('', true));
                    }
                    foreach (array_keys($hooks) as $hook) {
                        if ($block == 'side_tag_cloud') {
                            if (substr($hook, -1) == 'y') {
                                $hook .= ',' . substr($hook, 0, strlen($hook) - 1) . 'ies';
                            } elseif (substr($hook, -1) != 's' && $hook != 'quiz') {
                                $hook .= ',' . $hook . 's';
                            }
                        }
                        $list->attach(form_input_list_entry($hook, $hook == $default));
                    }
                    if ($block == 'main_search' && $parameter == 'limit_to' || $block == 'side_tag_cloud') {
                        $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, 0));
                    } else {
                        $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                    }
                } elseif (($default == '0' || $default == '1' || strpos($description, '\'0\'') !== false || strpos($description, '\'1\'') !== false) && do_lang('BLOCK_IND_WHETHER') != '' && strpos(strtolower($description), do_lang('BLOCK_IND_WHETHER')) !== false) {
                    $fields->attach(form_input_tick(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '1'));
                } elseif (do_lang('BLOCK_IND_NUMERIC') != '' && strpos($description, do_lang('BLOCK_IND_NUMERIC')) !== false) {
                    $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '' ? NULL : intval($default), false));
                } else {
                    $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default, false));
                }
            }
        }
        $keep = symbol_tempcode('KEEP');
        $post_url = find_script('block_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate();
        if (get_param('utheme', '') != '') {
            $post_url .= '&utheme=' . get_param('utheme');
        }
        $post_url .= '&block_type=' . $type_wanted;
        if (get_param('save_to_id', '') != '') {
            $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id'));
            $submit_name = do_lang_tempcode('SAVE');
            // Allow remove option
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => '')));
            $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false));
        } else {
            $submit_name = do_lang_tempcode('USE');
        }
        $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
        if (is_null($block_description)) {
            $block_description = '';
        }
        $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
        if (is_null($block_use)) {
            $block_use = '';
        }
        if ($block_description == '' && $block_use == '') {
            $text = new ocp_tempcode();
        } else {
            $text = do_lang_tempcode('BLOCK_HELPER_2', escape_html(cleanup_block_name($block)), escape_html($block_description), escape_html($block_use));
        }
        $hidden = form_input_hidden('block', $block);
        $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => true, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme()));
        if ($fields->is_empty()) {
            $type = 'step3';
        }
    }
    if ($type == 'step3') {
        require_javascript('javascript_posting');
        require_javascript('javascript_editing');
        $field_name = get_param('field_name');
        $bparameters = '';
        $bparameters_xml = '';
        $bparameters_tempcode = '';
        $block = trim(either_param('block'));
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (in_array('param', $parameters)) {
            $_parameters = array('param');
            unset($parameters[array_search('param', $parameters)]);
            $parameters = array_merge($_parameters, $parameters);
        }
        foreach ($parameters as $parameter) {
            $value = post_param($parameter, NULL);
            if (is_null($value)) {
                if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) {
                    continue;
                }
                // If not on form, continue, otherwise must be 0
                $value = '0';
            }
            if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) {
                if ($parameter == 'param') {
                    $bparameters .= '="' . str_replace('"', '\\"', $value) . '"';
                } else {
                    $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"';
                }
                $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />';
                $bparameters_tempcode .= ',' . $parameter . '=' . str_replace(',', '\\,', $value);
            }
        }
        $comcode = '[block' . $bparameters . ']' . $block . '[/block]';
        $comcode_xml = '<block>' . $bparameters_xml . $block . '</block>';
        $tempcode = '{$BLOCK,block=' . $block . $bparameters_tempcode . '}';
        if ($type_wanted == 'template') {
            $comcode = $tempcode;
        }
        // This is what will be written in
        $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false);
        $content = do_template('BLOCK_HELPER_DONE', array('_GUID' => '575d6c8120d6001c8156560be518f296', 'TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $block, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml));
    }
    global $EXTRA_HEAD;
    if (!isset($EXTRA_HEAD)) {
        $EXTRA_HEAD = new ocp_tempcode();
    }
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('BLOCK_HELPER'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}