Exemplo n.º 1
0
 function count($sub = 'root')
 {
     global $lg_gallery;
     $location = $lg_gallery->root . $this->curdir;
     $numfiles = 0;
     $subfiles = 0;
     if ($dir_content = @opendir($location)) {
         while (false !== ($dir_file = readdir($dir_content))) {
             if ('subfolders' == $sub && $lg_gallery->valid_dir($location . $dir_file)) {
                 $subfolder = new LazyestFolder($this->curdir . $dir_file);
                 if (false != $subfolder) {
                     $subfiles += $subfolder->count($sub);
                 }
                 unset($subfolder);
             }
             if (is_readable($location . $dir_file) && 0 < preg_match("/^.*\\.(jpg|gif|png|jpeg)\$/i", $dir_file)) {
                 if (!$this->is_folder_icon($dir_file)) {
                     $numfiles++;
                 }
             }
         }
         @closedir($dir_content);
     } else {
         return false;
     }
     return 'subfolders' == $sub ? $numfiles + $subfiles : $numfiles;
 }
Exemplo n.º 2
0
    /**
     * LazyestUploadTab::insert_folder_shortcode()
     * Form to insert a folder shortcode
     * 
     * @param LazyestFolder $folder
     * @return void
     */
    function insert_folder_shortcode($folder)
    {
        if (!$folder->valid()) {
            esc_html_e('Error opening folder', 'lazyest-gallery');
            return;
        }
        $folder->open();
        $count = $folder->count();
        $selectimages = sprintf('<option value="">%s</option>', esc_html__('Default', 'lazyest-gallery'));
        for ($i = 1; $i <= $count; $i++) {
            $selectimages .= sprintf('<option value="%s">%s</option>', $i, $i);
        }
        $selectcolumns = sprintf('<option value="">%s</option>', esc_html__('Default', 'lazyest-gallery'));
        for ($i = 1; $i <= 10; $i++) {
            $selectcolumns .= sprintf('<option value="%s">%s</option>', $i, $i);
        }
        ?>
  
    <input type="hidden" name="lg_folder" value="<?php 
        echo urlencode($folder->curdir);
        ?>
" />
    <div class="media-item">
    <table class="describe" id="lg_st_<?php 
        echo $folder->id;
        ?>
">
      <thead>
        <tr><th colspan="2"><?php 
        esc_html_e('Folder shortcode', 'lazyest-gallery');
        ?>
</th></tr>            
      </thead>
      <tbody>
        <tr>
          <th class="label" scope="row"><label for="count"><?php 
        esc_html_e('Number of images', 'lazyest-gallery');
        ?>
</label></th>
          <td><select name="count"><?php 
        echo $selectimages;
        ?>
</select></td>            
        </tr>
        <tr>          
          <th class="label" scope="row"><label for="column"><?php 
        esc_html_e('Number of columns', 'lazyest-gallery');
        ?>
</label></th>
          <td><select name="column"><?php 
        echo $selectcolumns;
        ?>
</select></td>            
        </tr>
        <tr>
          <th class="label" scope="row"><label for="paging"><?php 
        esc_html_e('Add pagination', 'lazyest-gallery');
        ?>
</label></th>
          <td><input type="checkbox" name="paging" /></td>
        </tr>
        <tr class="submit">
          <td></td>
          <td>
            <input class="button" type="submit" name="folder_short" value="<?php 
        esc_html_e('Insert as shortcode', 'lazyest-gallery');
        ?>
" />
            <input class="button" type="submit" name="folder_slide" value="<?php 
        esc_html_e('Insert as slide show', 'lazyest-gallery');
        ?>
" />          
          </td>
        </tr>
      </tbody>
      </table>
    </div>
    <?php 
    }
Exemplo n.º 3
0
/**
 * lg_folder_subcount()
 * Display the number of images in subfolders
 * 
 * @since 1.1.0
 * @return void
 */
function lg_folder_subcount()
{
    global $lg_gallery;
    $result = ' ';
    if (isset($_POST['folder'])) {
        $subcount = $allcount = 0;
        if ('' != $_POST['folder']) {
            // get # of images in subfolders of folder
            $folder = new LazyestFolder(urldecode($_POST['folder']));
            $count = (int) $folder->count();
            $allcount = (int) $folder->count('subfolders');
            $subcount = $allcount - $count;
            $allcount = 'separate' == $lg_gallery->get_option('count_subfolders') || 'none' == $lg_gallery->get_option('count_subfolders') ? $count : $allcount;
        } else {
            // get # of images in gallery
            $folders = $lg_gallery->folders('root', 'hidden');
            for ($i = 0; $i != count($folders); $i++) {
                $folder = $folders[$i];
                $subcount += $folder->count('subfolders');
            }
        }
        if (!isset($_POST['allcount'])) {
            if (0 < $subcount) {
                $result .= sprintf(esc_html__('%s in folders', 'lazyest-gallery'), strval($subcount));
            } else {
                if ('' == $_POST['folder']) {
                    $result .= sprintf(esc_html__('%s in folders', 'lazyest-gallery'), strval($subcount));
                }
            }
        } else {
            $result .= sprintf('%s %s', $allcount, $lg_gallery->get_option('listed_as'));
        }
    }
    echo $result;
    die;
}