Esempio n. 1
0
			<tr valign="top">
				<td>
	';
    // show the search field and the checkboxes
    //TODO redisplay var checkbox when Friendly names are working.  "display:none" allows the element
    //to still exist for js purposes -- otherwise we'll need to remove the references to it in the js
    //to avoid errors.  That's more work now and more work later when we want to reenable it.  The
    //functionality is harmess even in its present state, so it doesn't hurt much to leave it in
    //like this.
    echo '
					<div><input type="text" value="' . $vbphrase['search_stylevar'] . '" id="stylevar_filter" class="filterbox_inactive bginput smallfont" size="15" value="' . $vbphrase['search_stylevar'] . '" title="' . $vbphrase['search_stylevar'] . '" /></div>
					<div><label><input type="checkbox" id="hide_vars" />' . $vbphrase['hide_variables'] . '</label></div>
					<div style="display:none"><label><input type="checkbox" id="show_var_names" />' . $vbphrase['show_variable_names'] . '</label></div>
		';
    // show the form for the $vbulletin->GPC['dostyleid']
    $stylevars = fetch_stylevars_array();
    // $stylevars['group']['stylevarid']['styleid'] = $stylevar (record array from db);
    echo "\r\n\t\t\t\t\t<div><select size='25' multiple='multiple' class='leftcontrol' id='varlist'>\r\n\t";
    $groups = array_keys($stylevars);
    $js_stylevarlist_array = array();
    foreach ($groups as $group) {
        //TODO use friendly name once we figure that out.
        echo "\r\n\t\t\t\t\t\t<optgroup label='{$group}'>\r\n\t\t";
        $stylevarids = array_keys($stylevars[$group]);
        foreach ($stylevarids as $stylevarid) {
            if ($stylevarid) {
                // build JS stylevar array
                $js_stylevarlist_array[] = "\"{$stylevarid}\" : \"{$stylevarid}\"";
                //TODO use friendly name once we figure that out.
                echo "\r\n\t\t\t\t\t<option id='varlist_stylevar{$stylevarid}' value='" . $stylevarid . "'>{$stylevarid}</option>\r\n\t\t\t\t";
            }
    protected function fetch_stylevar_input($stylevarid, $input_type, $stylevar_value)
    {
        global $vbphrase;
        $vb5_config =& vB::getConfig();
        if (!$vb5_config['Misc']['debug']) {
            return '';
        }
        $autocomplete_js = '';
        if (self::$need_stylevar_autocomplete_js == true) {
            // This relies on GPC['dostyleid']. We're assuming this won't change in a way where you can edit multiple styles at the same time.
            $style = fetch_stylevars_array();
            $global_groups = array('Global');
            $global_stylevars = array();
            foreach ($global_groups as $group) {
                if (!isset($style[$group])) {
                    continue;
                }
                foreach ($style[$group] as $global_stylevarid => $global_stylevar) {
                    $global_stylevar = unserialize($global_stylevar['value']);
                    if (empty($global_stylevar)) {
                        continue;
                    }
                    foreach (array_keys($global_stylevar) as $type) {
                        if (strpos($type, 'stylevar_') === 0) {
                            continue;
                        }
                        $global_stylevars[] = "'" . vB_Template_Runtime::escapeJS($global_stylevarid) . '.' . $type . "'";
                    }
                }
            }
            $autocomplete_js .= "\n<script type=\"text/javascript\" src=\"" . vB::getDatastore()->getOption('bburl') . "/../js/jquery/jquery-ui-1.8.14.custom.min.js?v=" . SIMPLE_VERSION . "\"></script>\n\r" . '<script type="text/javascript">
				//<!--
				(function($) {
					$(document).ready(function(){
						var stylevars = [' . implode(', ', $global_stylevars) . '];
						$(".stylevar-autocomplete")
							.autocomplete({
								source: stylevars,
								appendTo: ".stylevar-autocomplete-menu",
								minLength: 0
							})
							.focus(function(){
								$(this).autocomplete("search", "");
							})
					});
				})(jQuery);
				//-->
				</script>
				<div class="stylevar-autocomplete-menu"></div>';
            self::$need_stylevar_autocomplete_js = false;
        }
        $stylevar_name = 'stylevar[' . $stylevarid . '][stylevar_' . $input_type . ']';
        $stylevar_title_attr = "title=\"name=&quot;{$stylevar_name}&quot;\"";
        $uniqueid = fetch_uniqueid_counter();
        return ' ' . $vbphrase['or_stylevar_part'] . ' ' . "<input name=\"{$stylevar_name}\" id=\"inp_{$stylevar_name}_{$uniqueid}\" class=\"stylevar-autocomplete\" value=\"" . htmlspecialchars_uni($stylevar_value) . "\" " . "tabindex=\"1\" size=\"35\" {$stylevar_title_attr}  data-options-id=\"sel_{$stylevar_name}_{$uniqueid}\" />\n" . $autocomplete_js;
    }