function lg_list_folders($title, $root = '')
{
    global $gallery_root, $user_level;
    if ($user_level == '') {
        $user_level = 1;
    }
    if ($root == '') {
        $root = $gallery_root;
        echo "\n" . $title;
    }
    $gallery_uri = get_option('lg_gallery_uri');
    // Fix for permalinks
    if (strlen(get_option('permalink_structure')) != 0) {
        $gallery_uri = $gallery_uri . '?';
    } else {
        $gallery_uri = $gallery_uri . '&';
    }
    $images = array();
    // Open gallery root
    if ($dir_handler = opendir($root)) {
        $forbidden = get_option('lg_excluded_folders');
        array_push($forbidden, "..");
        array_push($forbidden, ".");
        array_push($forbidden, "captions.xml");
        while ($file = readdir($dir_handler)) {
            if (!in_array($file, $forbidden) && is_dir($root . $file . '/')) {
                echo "\n<ul><li>\n\t";
            }
            if ($user_level < get_minimum_folder_level($file)) {
                array_push($forbidden, $file);
            }
            if (!in_array($file, $forbidden)) {
                // Do not remove the trailing slash (/)
                if (is_dir($root . $file . '/')) {
                    $filelink = explode($gallery_root, $root . $file);
                    echo '<a href="' . $gallery_uri . 'file=' . $filelink[1] . '/">' . $file . '</a>' . "\n";
                    lg_list_folders($title, $root . $file . '/');
                }
            }
            if (!in_array($file, $forbidden) && is_dir($root . $file . '/')) {
                echo "\n</li></ul>\n\t";
            }
        }
    } else {
        echo "\n<ul><li>\n\t";
        _e('Cannot open gallery root', $lg_text_domain);
        echo "\n</li></ul>\n\t";
    }
}
Exemple #2
0
    /**
     * Lazyest_Widget_List_Folders::widget()
     * 
     * @since 1.1.20
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $lg_gallery;
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('LG Folders', 'lazyest-gallery') : $instance['title'], $instance, $this->id_base);
        ?>
		
		<?php 
        echo $before_widget;
        ?>

		<?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>

		<div class="lazyest-list-folders">		
			<?php 
        lg_list_folders('');
        ?>

		</div>
		<?php 
        echo $after_widget;
    }