public function get_html($data = null, $title = null, $backtrace = 1) { if ($this->is_on('html') !== true) { return; } $from = ''; $html = '<!-- ' . $this->display_name . ' debug'; $stack = debug_backtrace(); if (!empty($stack[$backtrace]['class'])) { $from .= $stack[$backtrace]['class'] . '::'; } if (!empty($stack[$backtrace]['function'])) { $from .= $stack[$backtrace]['function']; } if ($data === null) { //$this->log( 'truncating debug log' ); $data = $this->buffer; $this->buffer = array(); } if (!empty($from)) { $html .= ' from ' . $from . '()'; } if (!empty($title)) { $html .= ' ' . $title; } if (!empty($data)) { $html .= ' : '; if (is_array($data)) { $html .= "\n"; $is_assoc = SucomUtil::is_assoc($data); if ($is_assoc) { ksort($data); } foreach ($data as $key => $val) { $html .= $is_assoc ? "\t{$key} = {$val}\n" : "\t{$val}\n"; } } else { if (preg_match('/^Array/', $data)) { $html .= "\n"; } // check for print_r() output $html .= $data; } } $html .= ' -->' . "\n"; return $html; }
/** * Loops through the arrays (1 to 3 dimensions) and calls get_single_tag() for each */ private function get_tag_array($tag = 'meta', $type = 'property', $tag_array, $use_post = false) { if ($this->p->debug->enabled) { $this->p->debug->log(count($tag_array) . ' ' . $tag . ' ' . $type . ' to process'); $this->p->debug->log($tag_array); } $ret = array(); if (empty($tag_array)) { return $ret; } elseif (!is_array($tag_array)) { if ($this->p->debug->enabled) { $this->p->debug->log('exiting early: tag_array argument is not an array'); } return $ret; } foreach ($tag_array as $f_name => $f_val) { // 1st-dimension array (associative) if (is_array($f_val)) { foreach ($f_val as $s_num => $s_val) { // 2nd-dimension array if (SucomUtil::is_assoc($s_val)) { foreach ($s_val as $t_name => $t_val) { // 3rd-dimension array (associative) $ret = array_merge($ret, $this->get_single_tag($tag, $type, $t_name, $t_val, $f_name . ':' . ($s_num + 1), $use_post)); } } else { $ret = array_merge($ret, $this->get_single_tag($tag, $type, $f_name, $s_val, $f_name . ':' . ($s_num + 1), $use_post)); } } } else { $ret = array_merge($ret, $this->get_single_tag($tag, $type, $f_name, $f_val, '', $use_post)); } } return $ret; }
public function get_select($name, $values = array(), $class = '', $id = '', $is_assoc = false, $disabled = false, $selected = false, $reload = false) { if (empty($name) || !is_array($values)) { return; } if ($is_assoc === false) { $is_assoc = SucomUtil::is_assoc($values); } $html = ''; $select_id = empty($id) ? 'select_' . $name : 'select_' . $id; if ($reload === true) { $url = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; $url .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $url = add_query_arg(array($name => '%%' . $name . '%%'), $url); $html .= ' <script type="text/javascript"> jQuery(function(){ jQuery("#' . $select_id . '").change(function(){ url="' . $url . '"+jQuery(location).attr("hash"); window.location=url.replace("%%' . $name . '%%", this.value); }); }); </script>'; } $html .= '<select name="' . $this->options_name . '[' . $name . ']"' . (empty($class) ? '' : ' class="' . $class . '"') . ' id="' . $select_id . '"' . ($disabled === true ? ' disabled="disabled"' : '') . '>' . "\n"; foreach ($values as $val => $desc) { // if the array is NOT associative (so regular numered array), // then the description is used as the saved value as well if ($is_assoc == false) { $val = $desc; } if ($val == -1) { $desc = _x('(settings value)', 'option value', $this->text_dom); } else { if ($this->text_dom) { $desc = _x($desc, 'option value', $this->text_dom); } switch ($name) { case 'og_img_max': if ($desc === 0) { $desc .= ' ' . _x('(no images)', 'option value', $this->text_dom); } break; case 'og_vid_max': if ($desc === 0) { $desc .= ' ' . _x('(no videos)', 'option value', $this->text_dom); } break; default: if ($desc === '' || $desc === 'none') { $desc = _x('[none]', 'option value', $this->text_dom); } break; } if ($this->in_defaults($name) && $val === $this->defaults[$name]) { $desc .= ' ' . _x('(default)', 'option value', $this->text_dom); } } $html .= '<option value="' . esc_attr($val) . '"'; if ($selected !== false) { $html .= selected($selected, $val, false); } elseif ($this->in_options($name)) { $html .= selected($this->options[$name], $val, false); } $html .= '>' . $desc . '</option>' . "\n"; } $html .= '</select>' . "\n"; return $html; }
/** * Loops through the arrays (1 to 3 dimensions) and calls get_single_tag() for each */ private function get_tag_array($tag = 'meta', $type = 'property', $tag_array) { $this->p->debug->log(count($tag_array) . ' ' . $tag . ' ' . $type . ' to process'); $this->p->debug->log($tag_array); $ret = array(); if (empty($tag_array)) { return $ret; } foreach ($tag_array as $f_name => $f_val) { // 1st-dimension array (associative) if (is_array($f_val)) { foreach ($f_val as $s_num => $s_val) { // 2nd-dimension array if (SucomUtil::is_assoc($s_val)) { ksort($s_val); foreach ($s_val as $t_name => $t_val) { // 3rd-dimension array (associative) $ret = array_merge($ret, $this->get_single_tag($tag, $type, $t_name, $t_val, $f_name . ':' . ($s_num + 1))); } } else { $ret = array_merge($ret, $this->get_single_tag($tag, $type, $f_name, $s_val, $f_name . ':' . ($s_num + 1))); } } } else { $ret = array_merge($ret, $this->get_single_tag($tag, $type, $f_name, $f_val)); } } return $ret; }
public function get_select($name, $values = array(), $class = '', $id = '', $is_assoc = false, $disabled = false) { if (empty($name) || !is_array($values)) { return; } if ($is_assoc === false) { $is_assoc = SucomUtil::is_assoc($values); } $html = '<select name="' . $this->options_name . '[' . $name . ']"' . (empty($class) ? '' : ' class="' . $class . '"') . (empty($id) ? '' : ' id="' . $id . '"') . ($disabled === true ? ' disabled="disabled"' : '') . '>'; foreach ($values as $val => $desc) { // if the array is NOT associative (so regular numered array), // then the description is used as the saved value as well if ($is_assoc == false) { $val = $desc; } if ($val == -1) { $desc = '(value from settings)'; } else { switch ($name) { case 'og_img_max': if ($desc === 0) { $desc .= ' (no images)'; } break; case 'og_vid_max': if ($desc === 0) { $desc .= ' (no videos)'; } break; default: if ($desc === '' || $desc === 'none') { $desc = '[none]'; } break; } if ($this->in_defaults($name) && $val === $this->defaults[$name]) { $desc .= ' (default)'; } } $html .= '<option value="' . esc_attr($val) . '"'; if ($this->in_options($name)) { $html .= selected($this->options[$name], $val, false); } $html .= '>' . $desc . '</option>'; } $html .= '</select>'; return $html; }