Exemplo n.º 1
0
  public function debug($args = array()) {
    
    global $wf;
    
    $r = array();
    
    $parse = true;
    
    if (is_string($args)) {
      
      $check = explode("&", $args);
      $check_2 = explode("=", $check[0]);
      
      if (count($check_2) == 1) {
        $parse = false;
        // simple label
        $r["l"] = $check_2[0];
        $r["pre"] = true;
      }
    }
    
    if ($parse) {
      
      $r = wp_parse_args( 
        $args, 
        array(
          "pre" => "1"
        )
      );
    
    } 
  
    if (isset($r["l"])) {
      echo '<h2 class="debug-label">'.$r["l"].'</h2>';
    }
    
    if (WOOF::is_true_arg($r, "pre")) {
      echo "<pre>";
    }
  
    $data = $this->debug_data();
    
    $class = get_class( $this );
    
		$my_class = $class;
		
    $parents = array();
    
    if (is_object($data)) {
      $data = (array) $data;
    } else if (!is_array($data)) {
      $data = array("value" => $data);
    }
  
    while ($class = get_parent_class($class)) {
      $parents[] = WOOF_HTML::tag("a", "target=_blank&href=" . $wf->woof_docs_base . WOOF_Inflector::dasherize($class), $class);
    }
       
    $data = array(
			"EXTENDS" => implode(", ", $parents),
			"site_id" => $this->_site_id
		) + $data;
    
		// TODO - add support for displaying collection items in this new format
		
		$out = preg_replace("/^Array/", WOOF_HTML::tag("a", "target=_blank&href=" . $wf->woof_docs_base . WOOF_Inflector::dasherize($my_class) , $my_class), print_r($data, true));
		
		echo $out;
    
    if (WOOF::is_true_arg($r, "pre")) {
      echo "</pre>";
    }
    
    return false;
    
  }