function outputTree($post, $firstLine = false)
{
    $outputString = "[{v:'" . $post->ID . "',f:'<h3>" . str_replace("'", "\\'", $post->post_title) . "</h3>";
    //price
    $outputString .= isset($post->metadata['Price'][0]) && $post->metadata['Price'][0] > 0 ? '<p>$' . $post->metadata['Price'][0] . '</p>' : '';
    //buttons
    $outputString .= '<div class="button-group"><a href="' . get_bloginfo('url') . '/wp-admin/post-new.php?post_type=decision_node&parent_id=' . $post->ID . '" class="button button-small">Add New</a><a href="' . get_edit_post_link($post->ID) . '" class="button button-small">Edit</a><a href="?post_type=decision_node&page=cftp_dt_visualise&post_id=' . $post->ID . '" class="button button-small">Tree</a></div>\'}';
    //parent
    $outputString .= $firstLine == true ? ",''],\n" : ", '" . $post->post_parent . "'],\n";
    echo $outputString;
    if (isset($post->children) && count($post->children) > 0) {
        foreach ($post->children as $key => $singlePost) {
            outputTree($singlePost, false);
        }
    }
}
Example #2
0
function outputTree($files, $indent = 1)
{
    //echo "<table style=\"font-size: 7pt; width: 100%;\"";
    foreach ($files as $k => $v) {
        $entry = isset($v['filename']) ? $v['filename'] : $k;
        $size = $v['size'];
        if ($indent == 0) {
            // root
            $is_folder = true;
        } elseif (is_array($v) && (!array_key_exists('filename', $v) && !array_key_exists('size', $v))) {
            // normal node
            $is_folder = true;
        } else {
            // leaf node, i.e. a file
            $is_folder = false;
        }
        if ($is_folder) {
            // we could output a folder icon here
        } else {
            // we could output an appropriate icon
            // based on file extension here
            $ext = pathinfo($entry, PATHINFO_EXTENSION);
        }
        // echo "<tr><td style=\"border: 1px solid #D2D2D2;\">";
        echo $entry;
        // output folder name or filename
        if (!$is_folder) {
            // if it’s not a folder, show file size
            echo " (" . makesize($size) . ")";
        }
        //echo "</td></tr>";
        if (is_array($v) && $is_folder) {
            outputTree($v, $indent + 1);
        }
    }
    //echo "</table>";
}
        if ($matchFile != '') {
            if (@$loadedFileList[$matchFile] == null) {
                combineFile($matchFile);
                $contentList[] = "\n";
            }
        } else {
            $contentList[] = $value;
        }
    }
    $treeIndex--;
}
function parseCSS($cssContent)
{
    //去掉注释
    $cssContent = preg_replace('/\\/\\*[\\d\\D]+?\\*\\//i', '', $cssContent);
    //去掉换行符
    $cssContent = preg_replace('/[\\n\\r]*/i', '', $cssContent);
    //去掉{}内最后一个分号
    $cssContent = preg_replace('/;\\s*?}/i', "}\n", $cssContent);
    //去页面内编码格式
    $cssContent = "@charset 'utf-8';\n" . preg_replace('/\\@charset ([\'\\"]).*?\\1;?/i', '', $cssContent);
    return $cssContent;
}
combineFile($f);
outputTree();
$outputContent = join($contentList, '');
if ($t == 'css') {
    echo parseCSS($outputContent);
} elseif ($t == 'js') {
    echo $outputContent;
}