protected function print_background_output() { global $vbphrase; $image = $this->value['image']; if ($this->value['image'] != "" && !strpos($image,'http://')) /* see if image location is relative or not */ { /* this assumes that the images folder is stored in root directory might need to fix this one day */ $image = str_replace('(','(../',$image); } $background_preview_js = ''; if (self::$need_background_preview_js) { $background_preview_js = ' <script type="text/javascript"> <!-- function previewBackground(stylevar) { /** * @param string name of the stylevar * @param string the item you want to fetch (color, background image, repeat, etc) * @return string the value from the form element */ var fetch_form_element_value = function(stylevar, item) { var wrapperid = "ctrl_stylevar[" + stylevar + "][" + item + "]"; var wrapper = YAHOO.util.Dom.get(wrapperid); // input for color, image, and offsets var formel = wrapper.getElementsByTagName("input"); if (formel && formel[0]) { return formel[0].value; } // select for background repeat and units formel = wrapper.getElementsByTagName("select"); if (formel && formel[0]) { return formel[0].value; } }; var backgroundString = ""; backgroundString += fetch_form_element_value(stylevar, "color"); // Fix the image path. This assumes the images folder is stored in root directory var image_path = fetch_form_element_value(stylevar, "image"); var abs_image_path = image_path.match(/^https?:\/\//i); if (!abs_image_path) { image_path = image_path.replace("(", "(../"); } backgroundString += " " + image_path; backgroundString += " " + fetch_form_element_value(stylevar, "repeat"); var offset_units = fetch_form_element_value(stylevar, "units"); backgroundString += " " + fetch_form_element_value(stylevar, "x") + offset_units; backgroundString += " " + fetch_form_element_value(stylevar, "y") + offset_units; YAHOO.util.Dom.get("preview_bg_" + stylevar).style.background = backgroundString; } --> </script>'; self::$need_background_preview_js = false; } $cell = " <div id=\"preview_bg_" . $this->stylevarid . "\" style=\" background: " . $this->value['color'] . " " . $image . " " . $this->value['repeat'] . " " . $this->value['x'] . $this->value['units']. " " . $this->value['y'] . $this->value['units']. ";width:100%;height:30px;border:1px solid #000000;\"> </div>"; $label = '<a href="javascript:previewBackground(\'' . $this->stylevarid . '\');">'. $vbphrase['click_here_to_preview'] .' </a>'; print_label_row($label, $background_preview_js . $cell); }