Exemplo n.º 1
0
    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;
    }