/**
     * Returns printable array of property stats
     *
     *
     * @todo #property_stats is currently used in multiple instances when attribute list is displayed by groups.  Cannot remove to avoid breaking styles. - potanin@UD (11/5/2011)
     * @since 1.11
     * @args: exclude, return_blank, make_link
     */
    function draw_stats($args = false, $property = false)
    {
        global $wp_properties, $post;
        if (!$property) {
            $property = $post;
        }
        $property = prepare_property_for_display($property);
        if (is_array($property)) {
            $property = WPP_F::array_to_object($property);
        }
        $defaults = array('sort_by_groups' => 'false', 'display' => 'dl_list', 'show_true_as_image' => 'false', 'make_link' => 'true', 'hide_false' => 'false', 'first_alt' => 'false', 'return_blank' => 'false', 'include' => '', 'exclude' => '', 'include_clsf' => 'attribute', 'stats_prefix' => sanitize_key(WPP_F::property_label('singular')));
        if (!empty($wp_properties['configuration']['property_overview']['sort_stats_by_groups'])) {
            $defaults['sort_by_groups'] = $wp_properties['configuration']['property_overview']['sort_stats_by_groups'];
        }
        if (!empty($wp_properties['configuration']['property_overview']['show_true_as_image'])) {
            $defaults['show_true_as_image'] = $wp_properties['configuration']['property_overview']['show_true_as_image'];
        }
        extract($args = wp_parse_args($args, $defaults), EXTR_SKIP);
        $property_stats = array();
        $groups = isset($wp_properties['property_groups']) ? (array) $wp_properties['property_groups'] : array();
        /**
         * Determine if we should draw meta data.
         * The functionality below is related to WPP2.0
         * Now it just adds compatibility with new Denali versions
         */
        if ($include_clsf == 'detail') {
            $sort_by_groups = 'false';
            foreach ($wp_properties['property_meta'] as $k => $v) {
                if ($k == 'tagline') {
                    continue;
                }
                if (!empty($property->{$k})) {
                    $property_stats[$k] = array('label' => $v, 'value' => $property->{$k});
                }
            }
        } else {
            $property_stats = WPP_F::get_stat_values_and_labels($property, array('label_as_key' => 'false'));
        }
        /** Include only passed attributes */
        if (!empty($include)) {
            $include = !is_array($include) ? explode(',', $include) : $include;
            foreach ($property_stats as $k => $v) {
                if (!in_array($k, $include)) {
                    unset($property_stats[$k]);
                }
            }
        }
        /** Exclude specific attributes from list */
        if (!empty($exclude)) {
            $exclude = !is_array($exclude) ? explode(',', $exclude) : $exclude;
            foreach ($exclude as $k) {
                if (isset($property_stats[$k])) {
                    unset($property_stats[$k]);
                }
            }
        }
        if (empty($property_stats)) {
            return false;
        }
        //echo "<pre>"; print_r( $property_stats ); echo "</pre>"; die();
        //* Prepare values before display */
        $property_stats = apply_filters('wpp::draw_stats::attributes', $property_stats, $property);
        $stats = array();
        foreach ($property_stats as $tag => $data) {
            if (empty($data['value'])) {
                continue;
            }
            $value = $data['value'];
            $attribute_data = UsabilityDynamics\WPP\Attributes::get_attribute_data($tag);
            //** Do not show attributes that have value of 'value' if enabled */
            if ($hide_false == 'true' && $value == 'false') {
                continue;
            }
            //* Skip blank values (check after filters have been applied) */
            if ($return_blank == 'false' && empty($value)) {
                continue;
            }
            $value = html_entity_decode($value);
            //** Single "true" is converted to 1 by get_properties() we check 1 as well, as long as it isn't a numeric attribute */
            if (isset($attribute_data['data_input_type']) && $attribute_data['data_input_type'] == 'checkbox' && in_array(strtolower($value), array('true', '1', 'yes'))) {
                if ($show_true_as_image == 'true') {
                    $value = '<div class="true-checkbox-image"></div>';
                } else {
                    $value = __('Yes', ud_get_wp_property()->domain);
                }
            } else {
                if ($value == 'false') {
                    if ($show_true_as_image == 'true') {
                        continue;
                    }
                    $value = __('No', ud_get_wp_property()->domain);
                }
            }
            //* Make URLs into clickable links */
            if ($make_link == 'true' && WPP_F::isURL($value)) {
                $value = str_replace('&ndash;', '-', $value);
                $value = "<a href='{$value}' title='{$label}'>{$value}</a>";
            }
            //* Make emails into clickable links */
            if ($make_link == 'true' && WPP_F::is_email($value)) {
                $value = "<a href='mailto:{$value}'>{$value}</a>";
            }
            $data['value'] = $value;
            $stats[$tag] = $data;
        }
        if (empty($stats)) {
            return false;
        }
        if ($display == 'array') {
            if ($sort_by_groups == 'true' && is_array($groups)) {
                $stats = sort_stats_by_groups($stats);
            }
            return $stats;
        }
        $alt = $first_alt == 'true' ? "" : "alt";
        //** Disable regular list if groups are NOT enabled, or if groups is not an array */
        if ($sort_by_groups != 'true' || !is_array($groups)) {
            foreach ($stats as $tag => $data) {
                $label = $data['label'];
                $value = $data['value'];
                $alt = $alt == "alt" ? "" : "alt";
                switch ($display) {
                    case 'dl_list':
                        ?>
            <dt class="<?php 
                        echo $stats_prefix;
                        ?>
_<?php 
                        echo $tag;
                        ?>
 wpp_stat_dt_<?php 
                        echo $tag;
                        ?>
"><?php 
                        echo $label;
                        ?>
              <span class="wpp_colon">:</span></dt>
            <dd class="<?php 
                        echo $stats_prefix;
                        ?>
_<?php 
                        echo $tag;
                        ?>
 wpp_stat_dd_<?php 
                        echo $tag;
                        ?>
 <?php 
                        echo $alt;
                        ?>
"><?php 
                        echo $value;
                        ?>
              &nbsp;</dd>
            <?php 
                        break;
                    case 'list':
                        ?>
            <li class="<?php 
                        echo $stats_prefix;
                        ?>
_<?php 
                        echo $tag;
                        ?>
 wpp_stat_plain_list_<?php 
                        echo $tag;
                        ?>
 <?php 
                        echo $alt;
                        ?>
">
              <span class="attribute"><?php 
                        echo $label;
                        ?>
<span class="wpp_colon">:</span></span>
              <span class="value"><?php 
                        echo $value;
                        ?>
&nbsp;</span>
            </li>
            <?php 
                        break;
                    case 'plain_list':
                        ?>
            <span class="<?php 
                        echo $stats_prefix;
                        ?>
_<?php 
                        echo $tag;
                        ?>
 attribute"><?php 
                        echo $label;
                        ?>
:</span>
            <span class="<?php 
                        echo $stats_prefix;
                        ?>
_<?php 
                        echo $tag;
                        ?>
 value"><?php 
                        echo $value;
                        ?>
&nbsp;</span>
            <br/>
            <?php 
                        break;
                    case 'detail':
                        ?>
            <h4 class="wpp_attribute"><?php 
                        echo $label;
                        ?>
<span class="separator">:</span></h4>
            <p class="value"><?php 
                        echo $value;
                        ?>
&nbsp;</p>
            <?php 
                        break;
                }
            }
        } else {
            $stats_by_groups = sort_stats_by_groups($stats);
            $main_stats_group = $wp_properties['configuration']['main_stats_group'];
            foreach ($stats_by_groups as $gslug => $gstats) {
                ?>
        <div class="wpp_feature_list">
        <?php 
                if ($main_stats_group != $gslug || !@array_key_exists($gslug, $groups)) {
                    $group_name = @array_key_exists($gslug, $groups) ? $groups[$gslug]['name'] : __('Other', ud_get_wp_property()->domain);
                    ?>
          <h2 class="wpp_stats_group"><?php 
                    echo $group_name;
                    ?>
</h2>
        <?php 
                }
                switch ($display) {
                    case 'dl_list':
                        ?>
            <dl class="wpp_property_stats overview_stats">
            <?php 
                        foreach ($gstats as $tag => $data) {
                            ?>
              <?php 
                            $label = $data['label'];
                            $value = $data['value'];
                            ?>
              <?php 
                            $alt = $alt == "alt" ? "" : "alt";
                            ?>
              <dt class="<?php 
                            echo $stats_prefix;
                            ?>
_<?php 
                            echo $tag;
                            ?>
 wpp_stat_dt_<?php 
                            echo $tag;
                            ?>
"><?php 
                            echo $label;
                            ?>
</dt>
              <dd class="<?php 
                            echo $stats_prefix;
                            ?>
_<?php 
                            echo $tag;
                            ?>
 wpp_stat_dd_<?php 
                            echo $tag;
                            ?>
 <?php 
                            echo $alt;
                            ?>
"><?php 
                            echo $value;
                            ?>
                &nbsp;</dd>
            <?php 
                        }
                        ?>
            </dl>
            <?php 
                        break;
                    case 'list':
                        ?>
            <ul class="overview_stats wpp_property_stats list">
            <?php 
                        foreach ($gstats as $tag => $data) {
                            ?>
              <?php 
                            $label = $data['label'];
                            $value = $data['value'];
                            $alt = $alt == "alt" ? "" : "alt";
                            ?>
              <li class="<?php 
                            echo $stats_prefix;
                            ?>
_<?php 
                            echo $tag;
                            ?>
 wpp_stat_plain_list_<?php 
                            echo $tag;
                            ?>
 <?php 
                            echo $alt;
                            ?>
">
                <span class="attribute"><?php 
                            echo $label;
                            ?>
:</span>
                <span class="value"><?php 
                            echo $value;
                            ?>
&nbsp;</span>
              </li>
            <?php 
                        }
                        ?>
            </ul>
            <?php 
                        break;
                    case 'plain_list':
                        foreach ($gstats as $tag => $data) {
                            $label = $data['label'];
                            $value = $data['value'];
                            ?>
              <span class="<?php 
                            echo $stats_prefix;
                            ?>
_<?php 
                            echo $tag;
                            ?>
 attribute"><?php 
                            echo $label;
                            ?>
:</span>
              <span class="<?php 
                            echo $stats_prefix;
                            ?>
_<?php 
                            echo $tag;
                            ?>
 value"><?php 
                            echo $value;
                            ?>
&nbsp;</span>
              <br/>
            <?php 
                        }
                        break;
                }
                ?>
        </div>
      <?php 
            }
        }
    }