function dirToArray($dir)
{
    $contents = array();
    # Foreach node in $dir
    foreach (scandir($dir) as $node) {
        # Skip link to current and parent folder
        if ($node == '.') {
            continue;
        }
        if ($node == '..') {
            continue;
        }
        # Check if it's a node or a folder
        if (is_dir($dir . DIRECTORY_SEPARATOR . $node)) {
            # Add directory recursively, be sure to pass a valid path
            # to the function, not just the folder's name
            $contents[$node] = dirToArray($dir . DIRECTORY_SEPARATOR . $node);
        } else {
            # Add node, the keys will be updated automatically
            $contents[] = $node;
        }
    }
    # done
    return $contents;
}
Beispiel #2
0
function echoErrors($dirname)
{
    $dirarr = dirToArray($dirname);
    if (count($dirarr) > 0) {
        echo "<ul>";
        foreach ($dirarr as $key => $value) {
            $l = $dirname . $value;
            echo "<li><div class='error_item'><a href='{$l}'>" . $value . "</a></div></li>";
        }
        echo "</ul>";
    } else {
        echo "nothing to show";
    }
}
function dirToArray($dir)
{
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, array(".", ".."))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
            } else {
                $result[] = $value;
            }
        }
    }
    return $result;
}
Beispiel #4
0
function dirToArray($dir)
{
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $value) {
        if (!in_array($value, array(".", ".."))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result[] = array('name' => substr($value, strpos($value, '.') + 1, strlen($value)), 'children' => dirToArray($dir . DIRECTORY_SEPARATOR . $value), 'path' => $dir . DIRECTORY_SEPARATOR . $value . DIRECTORY_SEPARATOR);
            } else {
                $result[pathinfo($value, PATHINFO_EXTENSION)] = array('path' => $dir . DIRECTORY_SEPARATOR . $value, 'name' => pathinfo($value, PATHINFO_FILENAME));
            }
        }
    }
    return $result;
}
function dirToArray($dir)
{
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, array(".", "..", ".DS_Store", ".gitkeep", "controllers", "autoload.php"))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result = array_merge($result, dirToArray($dir . DIRECTORY_SEPARATOR . $value));
            } else {
                if (!preg_match("/^_(.*)+\$/i", $value)) {
                    $result[] = $dir . '/' . $value;
                }
            }
        }
    }
    return $result;
}
Beispiel #6
0
function dirToArray($dir)
{
    $ignore = array('.', '..', 'js', 'src', 'css', 'fonts', 'build', 'examples', 'assets');
    $result = array();
    $root = scandir($dir);
    $dirs = array_diff($root, $ignore);
    foreach ($dirs as $key => $value) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
            $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
        } else {
            if (substr($value, -3) == '.js') {
                $result[] = $value;
            }
        }
    }
    return $result;
}
function dirToArray($dir)
{
    $ignore = array('.', '..', '_site', 'assets', 'gfx', 'states', 'book', 'filters', 'misc', 'golf');
    $result = array();
    $root = scandir($dir);
    $dirs = array_diff($root, $ignore);
    foreach ($dirs as $key => $value) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
            $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
        } else {
            if (substr($value, -3) == '.js') {
                $result[] = $value;
            }
        }
    }
    return $result;
}
function dirToArray($dir) {
    $contents = array();
    foreach (scandir($dir) as $node) {
        if ($node == '.')  continue;
        if ($node == '..') continue;
		if (preg_match('/^\./',$node)) continue;
        if (is_dir($dir.DS.$node)) {
            if($node == 'admin') continue;
			if($dir === ROOT.DS.'scripts' && $node === 'tiny_mce') continue;
			$contents[$node] = dirToArray($dir.DS.$node);
			continue;
        }
		else {
            $contents[] = $node;
        }
    }
    return $contents;
}
Beispiel #9
0
function dirToArray($dir)
{
    global $total;
    $ignore = array('.', '..', 'assets', 'css', 'export', 'fonts', 'js', 'lib', 'src');
    $result = array();
    $root = scandir($dir);
    $dirs = array_diff($root, $ignore);
    foreach ($dirs as $key => $value) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
            $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
        } else {
            if ($value !== 'index.html' && substr($value, -5) === '.html') {
                $result[] = $value;
                $total++;
            }
        }
    }
    return $result;
}
Beispiel #10
0
function dirToArray($dir, $firstLevel = true)
{
    if (!$firstLevel) {
        $result = "<ul style='display:none'>";
    } else {
        $result = "<ul id='dirList'>";
    }
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, array(".", ".."))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result .= "<li><a href='#' class='collection-item' id='" . $dir . DIRECTORY_SEPARATOR . $value . "'>{$value}</a>";
                $result .= dirToArray($dir . DIRECTORY_SEPARATOR . $value, false);
                $result .= "</li>";
            }
        }
    }
    return $result . "</ul>";
}
/**
 * dirToArray
 * Returns a recursive array of the recursive directories
 * 
 * $dir:
 *      Folder to scan, starting at one folder up
 *      Ignores ., .. and "media"
 *      //TODO: Ignore an array argument of words
 *
 * @return:
 *      Array containing the recursive folder scan
 *      Ex:
 *      [Category] => [Content] =>
 *                    [Content 2] =>
 *      [Category 2] =>
 *
 */
function dirToArray($dir)
{
    /* Splitting the directory */
    $dirPath = explode(DIRECTORY_SEPARATOR, dirname(__FILE__));
    /* Moving to parent, adding selected directory */
    $dir = implode(DIRECTORY_SEPARATOR, array_pop($dirPath)) . "{$dir}";
    /* Grabbing the values */
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        /* Ignore current dir, previous dir and media folder */
        if (!in_array($value, array(".", "..", "media"))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
            }
        }
    }
    return $result;
}
Beispiel #12
0
function dirToArray($dir, $fix = "", &$first = true)
{
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
            dirToArray($dir . DIRECTORY_SEPARATOR . $file, $fix . $file . "/", $first);
        } elseif (!str_ends_with($file, ".php") && !str_ends_with($file, ".md5") && !str_ends_with($file, ".dat") && !str_starts_with($file, "installer")) {
            if ($first) {
                $first = false;
            } else {
                print "\r\n";
            }
            print $fix . $file;
        }
    }
    closedir($handle);
}
Beispiel #13
0
function dirToArray($dir)
{
    global $header;
    global $footer;
    $ignore = array('.', '..', 'assets', 'js', 'css', 'fonts', 'lib');
    $result = array();
    $root = scandir($dir);
    $dirs = array_diff($root, $ignore);
    foreach ($dirs as $key => $value) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
            $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
        } else {
            if (substr($value, -3) === '.js') {
                $src = file_get_contents($dir . $value);
                $output = $header . $src . $footer;
                $filename = str_replace('.js', '.html', $value);
                file_put_contents("../{$filename}", $output);
                echo "{$value} <br>";
            }
        }
    }
    return $result;
}
function dirToArray($dir, $level = 0, $exclude = "")
{
    //recursive function if $level !=0
    // if level ==1 , only scan given $dir
    if (!is_dir($dir)) {
        return false;
    }
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value) and $level === 1) {
            continue;
        }
        if (!in_array($value, array(".", "..", $exclude))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value) and $level === 0) {
                $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value, $level, $exclude);
            } else {
                $result[] = $value;
            }
        }
    }
    return $result;
}
Beispiel #15
0
function dirToArray($dir)
{
    global $src;
    $ignore = array('.', '..');
    $fileIgnore = array('p2.js');
    $result = array();
    $root = scandir($dir);
    $dirs = array_diff($root, $ignore);
    foreach ($dirs as $key => $value) {
        $path = realpath($dir . DIRECTORY_SEPARATOR . $value);
        if (is_dir($path)) {
            $result[$value] = dirToArray($path);
        } else {
            if (substr($value, -3) == '.js') {
                if (!in_array($value, $fileIgnore)) {
                    $index = str_replace($src, "", $path);
                    $index = substr($index, 1);
                    $result[substr($value, 0, -3)] = $index;
                }
            }
        }
    }
    return $result;
}
Beispiel #16
0
<?php

$smarty->assign('_allroles', 'YES');
if (!empty($session->tags)) {
    if ($session->tags) {
        $smarty->assign('_tags', 'YES');
    }
}
//debugBreak();
$dirs = dirToArray(DOCUMENT_ROOT, false, array(".", "..", "engine"));
$dirs = array2jstree($dirs);
$smarty->assign('_tree', $dirs);
Beispiel #17
0
<?php

if ($_SERVER['SERVER_NAME'] == '192.168.0.100' && isset($_GET['single']) == false) {
    $files = dirToArray('../../assets/fonts/arcadeFonts/8x8/');
} else {
    $files = dirToArray('assets/fonts/arcadeFonts/8x8/');
}
$total = 0;
function dirToArray($dir)
{
    global $total;
    $ignore = array('.', '..', 'Thumbs.db');
    $result = array();
    $root = scandir($dir);
    $dirs = array_diff($root, $ignore);
    foreach ($dirs as $key => $value) {
        if (substr($value, -4) === '.png') {
            $result[] = $value;
            $total++;
        }
    }
    return $result;
}
function printJSLinks($files)
{
    $output = "";
    foreach ($files as $key => $value) {
        if (is_string($value)) {
            $value2 = substr($value, 0, -4);
            // $file = urlencode($value);
            if ($value2 == 'Ninja Gaiden (Tecmo)') {
                e.preventDefault();
            };
        });
    });
  </script>


<?php 
//superprint($content_pack);
// convention for dirs : OBJECTS_FOLDER/object's class/
// and $content_process_page->classe == edited_objet->classe
if ($media_type) {
    $media_dir = MEDIA_FOLDER . "/" . $media_type . "/";
    $object_type = $media_type;
    $objects_dir = OBJECTS_FOLDER . "/" . $media_type . "/";
    $media_files = dirToArray($media_dir, 1, "index.php");
    //superprint($media_files);
    $data_module_section = $content_pack["page"]->module["section"];
    // the ID of each objects added later in the loop
    $editLink_base = BASEFILE . "?process=admin_" . MEDIA_MODULE_SECTION . "_edit";
    $deleteLink_base = BASEFILE . "?process=admin_" . MEDIA_MODULE_SECTION . "_update&process_request_operation=delete";
    $createLink_base = BASEFILE . "?process=admin_" . MEDIA_MODULE_SECTION . "_create&media_type=" . $media_type;
    $create_glyphicon = "<span class=\"glyphicon  glyphicon-plus\" ></span>\n";
    $createLinkButton = "<a href=\"" . $createLink_base . "\" title=\"create a new ";
    $createLinkButton .= $media_type . "\">" . $create_glyphicon . "</a>\n";
    ?>

    
    <table  cellpadding="0" cellspacing="0" border="0"  class="table table-striped table-hover compact" id="objects_list">

function dirToArray($dir)
{
    $result = array();
    $contents = scandir($dir);
    $bad = array(".", "..", ".DS_Store", "_notes", "Thumbs.db", "Browse.plb");
    $cdir = array_diff($contents, $bad);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, array(".", ".."))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
            } else {
                $result[] = $value;
            }
        }
    }
    return $result;
}
    $process_request_operation_status = $_GET["process_request_operation_status"];
}
if ($process_request_operation_status == "1") {
    include "system/display/messages/admin/data/feedback_update.php";
}
?>


<ul class="list-group">
    
    <?php 
$data_list_process_id = $content_pack["page"]->module["name"] . "_";
$data_list_process_id .= $content_pack["page"]->module["section"] . "_list";
foreach ($system_data_classes as $system_data_type) {
    $data_dir = OBJECTS_FOLDER . "/" . $system_data_type . "/";
    $data_files = dirToArray($data_dir, 1);
    $data_count = count($data_files) - 1;
    $data_list_baselink = BASEFILE . "?process=" . $data_list_process_id . "&object_type=" . $system_data_type;
    $data_list_link = "\n<a href=\"" . $data_list_baselink . "\" title=\"" . $data_list_process_id . "\">" . $system_data_type . "</a>\n";
    //$data_list_link.=$system_data_type."</a>\n";
    ?>
  <li class="list-group-item">
    <span class="badge"> <?php 
    echo $data_count;
    ?>
</span>
    <?php 
    echo $data_list_link;
    ?>
  </li>
  
Beispiel #21
0
header("HTTP/1.0 200");
if (!empty($_POST['callback'])) {
    $json->callback = $_POST['callback'];
}
if (!empty($_POST['fbAppId']) && $json->status == 'OK') {
    $fbAppId = $_POST['fbAppId'];
    if (!empty($_POST['session']) && $json->status == 'OK') {
        $sessionId = $_POST['session'];
        if ($memcache = new Memcache()) {
            if ($memcache->connect('localhost', 11211, 3)) {
                try {
                    if ($json->status == 'OK') {
                        $session = verify_session($memcache, $sessionId, $_SERVER, __DOMAIN__);
                        if (!empty($session)) {
                            if (!empty($session->admin) || !empty($session->developer) || !empty($session->content_creator)) {
                                $dirs = dirToArray(DOCUMENT_ROOT, false, array(".", "..", "templates", "_thumbs", "css", "js", "upload", "email_templates", "engine", "fonts", "plugins", "bootstrap", "php"));
                                $json->data = array2jstree($dirs);
                            }
                        } else {
                            $json->status = 'ERROR';
                            $json->message = 'Invalid session';
                        }
                    }
                } catch (PDOException $e) {
                    error_log(__FILE__ . ' : ' . $e->getMessage());
                    $json->status = 'ERROR';
                    $json->message = 'PDOException: ' . $e->getMessage();
                } catch (MemcacheException $e) {
                    error_log(__FILE__ . ' : ' . $e->getMessage());
                    $json->status = 'ERROR';
                    $json->message = 'MEMCACHEException: ' . $e->getMessage();
Beispiel #22
0
function dirToArray($dir)
{
    global $filelist;
    $ignore = array('.', '..', '.svn', '.git', 'index.php');
    $root = scandir($dir);
    $files = array_diff($root, $ignore);
    foreach ($files as $key => $value) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
            dirToArray($dir . DIRECTORY_SEPARATOR . $value);
        } else {
            if (substr($value, -3) == '.as') {
                $filelist[] = $dir . DIRECTORY_SEPARATOR . $value;
            }
        }
    }
}
}
if ($process_request_operation_status == "1") {
    include "system/display/messages/admin/data/media_feedback_update.php";
}
?>


<ul class="list-group">
    
    <?php 
$data_list_process_id = $content_pack["page"]->module["name"] . "_";
$data_list_process_id .= $content_pack["page"]->module["section"] . "_list";
foreach ($system_data_media as $system_data_type) {
    $data_dir = MEDIA_FOLDER . "/" . $system_data_type . "/";
    //superprint($data_dir);
    $data_files = dirToArray($data_dir, 1, "index.php");
    //$data_files = filesToArray($data_dir,"index.php");
    $data_count = count($data_files);
    $data_list_baselink = BASEFILE . "?process=" . $data_list_process_id . "&media_type=" . $system_data_type;
    $data_list_link = "\n<a href=\"" . $data_list_baselink . "\" title=\"" . $data_list_process_id . "\">" . $system_data_type . "s</a>\n";
    //$data_list_link.=$system_data_type."</a>\n";
    ?>
  <li class="list-group-item">
    <span class="badge"> <?php 
    echo $data_count;
    ?>
</span>
    <?php 
    echo $data_list_link;
    ?>
  </li>
    echo '<div class="updated" id="message">
			<p><strong>' . __("Changes Saved Successfully.", 'dxinvoice') . '</strong></p>
		</div>';
}
?>
		
	<form  method="post" action="options.php">		
		<?php 
$files = DX_INV_DIR . "/templates";
$dir = "";
$dx_google_callback_url = add_query_arg(array('page' => 'dx_invoice_google_settings'), admin_url('admin.php'));
$pred = scandir($files);
foreach ($pred as $key => $value) {
    if (!in_array($value, array(".", ".."))) {
        if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
            $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
        } else {
            $result[] = $value;
        }
    }
}
settings_fields('invoice_plugin_options');
$dx_invoice_options = get_option('dx_invoice_options');
$invoice_current = isset($dx_invoice_options['invoice_num']) ? $dx_invoice_options['invoice_num'] : "";
$invoice_increment = isset($dx_invoice_options['increment']) ? $dx_invoice_options['increment'] : "";
$invoice_stamp = isset($dx_invoice_options['stamp']) ? $dx_invoice_options['stamp'] : "";
$invoice_signature = isset($dx_invoice_options['signature']) ? $dx_invoice_options['signature'] : "";
$invoice_page_template = isset($dx_invoice_options['page_template']) ? $dx_invoice_options['page_template'] : "";
/*	Company Detail		*/
$dx_company_person = isset($dx_invoice_options['dx_company_person']) ? $dx_invoice_options['dx_company_person'] : "";
$dx_company_name = isset($dx_invoice_options['dx_company_name']) ? $dx_invoice_options['dx_company_name'] : "";
header("HTTP/1.0 200");
if (!empty($_POST['callback'])) {
    $json->callback = $_POST['callback'];
}
if (!empty($_POST['_fbAppId']) && $json->status == 'OK') {
    $fbAppId = $_POST['_fbAppId'];
    if (!empty($_POST['_session']) && $json->status == 'OK') {
        $sessionId = $_POST['_session'];
        if ($memcache = new Memcache()) {
            if ($memcache->connect('localhost', 11211, 3)) {
                try {
                    if ($json->status == 'OK') {
                        $session = verify_session($memcache, $sessionId, $_SERVER, __DOMAIN__);
                        if (!empty($session)) {
                            if (!empty($session->admin) || !empty($session->developer) || !empty($session->content_creator)) {
                                $dirs = dirToArray(DOCUMENT_ROOT, false);
                                $json->data = array2jstree($dirs);
                            }
                        } else {
                            $json->status = 'ERROR';
                            $json->message = 'Invalid session';
                        }
                    }
                } catch (PDOException $e) {
                    error_log(__FILE__ . ' : ' . $e->getMessage());
                    $json->status = 'ERROR';
                    $json->message = 'PDOException: ' . $e->getMessage();
                } catch (MemcacheException $e) {
                    error_log(__FILE__ . ' : ' . $e->getMessage());
                    $json->status = 'ERROR';
                    $json->message = 'MEMCACHEException: ' . $e->getMessage();
Beispiel #26
0
<?php

include "includes.php";
$db = new Database();
$db->connect();
$db->select("*", "files");
$filesTable = $db->getResult();
$files = array_column($filesTable, 'file_path');
$uploads = dirToArray("../Uploads");
foreach ($uploads as $upload) {
    if (!in_array($upload, $files)) {
        $fileUploader = new FileUploader($upload, $upload, "");
        $fileUploader->uploadFile();
    }
}
function dirToArray($dir)
{
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, array(".", ".."))) {
            if (!is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                //   $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
                //}else{
                $result[] = $value;
            }
        }
    }
    return $result;
}
Beispiel #27
0
<?php

$defaults = get_role_defaults($db, $memcache, $session);
$smarty->assign('_allroles', 'YES');
if (!empty($session->tags)) {
    if ($session->tags) {
        $smarty->assign('_tags', 'YES');
    }
    // set the request page
}
$dirs = dirToArray(DOCUMENT_ROOT, false, array(".", "..", "templates", "v1", "v1-engine", "_thumbs", "font-awesome", "css", "css-engine", "js", "js-engine", "fonts-engine", "images-engine", "bower_components", "libs", "smarty", "vendor", "ckeditor", "ckfinder", "font-awesome-4.2.0", "php", "rs-plugin", "upload"));
$dirs = array2jstree($dirs);
$smarty->assign('_tree', $dirs);
Beispiel #28
0
            <div class="wrapper">
                <header role="banner" class="page-header__box clearfix">
                    <div class="site-title"><a href="https://github.com/MichaelvanLaar/Website-Template-Starting-Point/">Website Template Starting Point&nbsp;3.3.3</a></div>
                </header> <!-- end of .page-header__box -->
            </div> <!-- end of .wrapper -->
        </div> <!-- end of .page-header -->


        <div class="[ main-navigation  js-main-navigation ]  clearfix">
            <div class="wrapper">
                <a href="#"><img src="media/common/wtsp-logo.png" width="50" height="50" alt="WTSP" class="main-navigation__logo"></a>
                <nav id="main-navigation" class="[ main-navigation__box  js-main-navigation__box ]  clearfix">
                    <div class="main-navigation__toggle  js-main-navigation__toggle">Navigation</div>
                    <!-- PLEASE NOTE: Classes and styling of the main navigation don’t follow
                         BEM-like naming conventions – with intent to be easily applicable to
                         almost any HTML code produced by a CMS. -->
                    <?php 
$posts = dirToArray("posts");
echo makeMenu($posts, 4, "blog", true);
?>
                </nav> <!-- end of .main-navigation__box -->
            </div> <!-- end of .wrapper -->
        </div> <!-- end of .page-main-navigation -->





        <div class="main-container clearfix">
            <div class="wrapper">
/**
 * @param string $directory
 * @return array
 */
function dirToArray($directory)
{
    $arrayItems = array();
    $skipByExclude = false;
    $handle = opendir($directory);
    if ($handle) {
        while (false !== ($file = readdir($handle))) {
            preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $file, $skip);
            if (!$skip && !$skipByExclude) {
                if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {
                    $arrayItems = array_merge($arrayItems, dirToArray($directory . DIRECTORY_SEPARATOR . $file));
                } else {
                    $file = $directory . DIRECTORY_SEPARATOR . $file;
                    $arrayItems[] = $file;
                }
            }
        }
        closedir($handle);
    }
    return $arrayItems;
}
Beispiel #30
0
    /**
     * Add field for displaying customers on the Invoice form 
     * 
     * @param $type field type (text, dx_invoicer_form_field, select, textarea...)
     * @param $item the item name
     * @param $attributes array with attributes
     * @param $method HTTP method where data is stored
     * @param $section_prefix a prefix for the section, if any
     * @param $id_prefix a prefix for IDs, if any
     */
    public function add_custom_templates($type, $item, $attributes, $method, $section_prefix, $id_prefix)
    {
        if ($type == 'dx_custom_templates') {
            //extract( $attributes );
            extract(array_merge($attributes, DX_Form_Helper::get_element_attributes($item, $attributes, $method)));
            $label = !empty($label) ? $label : "";
            $type = !empty($type) ? $type : "";
            $name = !empty($name) ? $name : "";
            $value = !empty($value) ? $value : "";
            $text = !empty($text) ? $text : "";
            $id = !empty($id) ? $id : "";
            $class = !empty($class) ? $class : "";
            $style = !empty($style) ? $style : "";
            $desc = !empty($desc) ? $desc : "";
            $initial_rows = 0;
            $current_user_id = get_current_user_id();
            $files = DX_INV_DIR . "/templates";
            $dir = "";
            $pred = scandir($files);
            foreach ($pred as $key => $rowvalue) {
                if (!in_array($rowvalue, array(".", ".."))) {
                    if (is_dir($dir . DIRECTORY_SEPARATOR . $rowvalue)) {
                        $result[$rowvalue] = dirToArray($dir . DIRECTORY_SEPARATOR . $rowvalue);
                    } else {
                        $result[] = $rowvalue;
                    }
                }
            }
            ob_start();
            ?>
			<tr>
				<th scope="row">
					<label for="<?php 
            echo $id_prefix . $id;
            ?>
"><?php 
            echo $text;
            ?>
</label>	
				</th>
				<td><select name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $id_prefix . $id;
            ?>
" <?php 
            echo $type == 'multiselect' ? 'multiple="multiple"' : '';
            ?>
 >
						<option id="dx_empty_customer" value=""><?php 
            _e('Pick an existing template', 'dxinvoice');
            ?>
</option>						
						<?php 
            foreach ($result as $singlefile) {
                ?>
								<option value="<?php 
                echo $singlefile;
                ?>
" <?php 
                selected($singlefile, $value);
                ?>
 ><?php 
                echo $singlefile;
                ?>
</option>
						<?php 
            }
            ?>
					</select><br />
					<span class="description"><?php 
            echo __('Add template if not exist.', 'dxinvoice');
            ?>
</span>
				</td>
			 </tr>
			<?php 
            $output = ob_get_clean();
            echo apply_filters('dx_invoice_filter_invoices_table', $output);
        }
    }