Ejemplo n.º 1
0
/**
 * @param EcrProjectBase $project
 *
 * @return string
 */
function drawFileTree(EcrProjectBase $project)
{
    ecrLoadMedia('php_file_tree');
    $ret = '';
    $javascript = '';
    $javascript .= " onclick=\"reflectFile('[folder]', '[file]', '[id]');\"";
    $jsFolder = '';
    $fileTree = new EcrFileTree('', '', $javascript, $jsFolder);
    foreach ($project->copies as $dir) {
        if (is_dir($dir)) {
            $d = str_replace(JPATH_ROOT, '', $dir);
            $dspl = str_replace(DS, ' ' . DS . ' ', $d);
            $ret .= '<div class="file_tree_path"><strong>JROOT</strong>' . BR . $dspl . '</div>';
            $fileTree->setDir($dir);
            $ret .= $fileTree->startTree();
            $ret .= $fileTree->drawTree();
            $ret .= $fileTree->endTree();
        } else {
            if (JFile::exists($dir)) {
                $show = true;
                foreach ($project->copies as $test) {
                    if (strpos($dir, $test)) {
                        $show = false;
                    }
                }
                if ($show) {
                    //--This shows a single file not included in anterior directory list ;) - hi plugins...
                    $fileName = JFile::getName(JPath::clean($dir));
                    $dirName = substr($dir, 0, strlen($dir) - strlen($fileName));
                    $oldDir = isset($oldDir) ? $oldDir : '';
                    if ($dirName != $oldDir) {
                        $d = str_replace(JPATH_ROOT, '', $dir);
                        $dspl = str_replace(DS, ' ' . DS . ' ', $d);
                        $ret .= '<div class="file_tree_path"><strong>JROOT</strong>' . BR . $dspl . '</div>';
                    }
                    $oldDir = $dirName;
                    if (false == isset($fileTree)) {
                        $fileTree = new EcrFileTree($dir, "javascript:", $javascript);
                    } else {
                        $fileTree->setDir($dir);
                    }
                    $ret .= $fileTree->startTree();
                    $ret .= $fileTree->getLink($dirName, $fileName);
                    $ret .= $fileTree->endTree();
                    $ret .= '<br />';
                }
            }
        }
    }
    return $ret;
}
Ejemplo n.º 2
0
/**
 *
 * @param $project
 * @return unknown_type
 */
function drawFileTree($project)
{
    $ret = '';
    $javascript = '';
    $javascript .= " onclick=\"create_skeleton('[link]', '[file]', '[id]');\"";
    $jsFolder = '';
    //    #$jsFolder .= " onmousedown=\"setPath('[link]/[file]');\"";
    $fileTree = new EcrFileTree('', '', $javascript, $jsFolder);
    foreach ($project->copies as $dir) {
        if (is_dir($dir)) {
            $dspl = str_replace(JPATH_ROOT . DS, '', $dir);
            $dspl = str_replace(DS, ' ' . DS . ' ', $dspl);
            $ret .= '<div class="file_tree_path"><strong>JROOT</strong>' . BR . $dspl . '</div>';
            $fileTree->setDir($dir);
            $ret .= $fileTree->startTree();
            $ret .= $fileTree->drawTree();
            $ret .= $fileTree->endTree();
        } else {
            if (JFile::exists($dir)) {
                $show = true;
                foreach ($project->copies as $test) {
                    if (strpos($dir, $test)) {
                        $show = false;
                    }
                }
                //foreach
                if (!$show) {
                    continue;
                }
                //-- This shows a single file not included in anterior directory list ;) - hi plugins...
                $fileName = JFile::getName(JPath::clean($dir));
                $dirName = substr($dir, 0, strlen($dir) - strlen($fileName));
                $oldDir = isset($oldDir) ? $oldDir : '';
                if ($dirName != $oldDir) {
                    $dspl = str_replace(JPATH_ROOT . DS, '', $dirName);
                    $ret .= '<div class="file_tree_path"><strong>JROOT</strong>' . BR . $dspl . '</div>';
                }
                $oldDir = $dirName;
                if (!isset($fileTree)) {
                    $fileTree = new EcrFileTree($dir, "javascript:", $javascript);
                } else {
                    $fileTree->setDir($dir);
                }
                $ret .= $fileTree->startTree();
                $ret .= $fileTree->getLink($dirName, $fileName);
                $ret .= $fileTree->endTree();
                $ret .= '<br />';
            }
        }
    }
    //foreach
    return $ret;
}