Ejemplo n.º 1
0
        function album_custom_column_content($column)
        {
            global $post;
            switch ($column) {
                case FOOGALLERY_CPT_ALBUM . '_template':
                    $album = FooGalleryAlbum::get($post);
                    $template = $album->album_template_details();
                    if (false !== $template) {
                        echo $template['name'];
                    }
                    break;
                case FOOGALLERY_CPT_ALBUM . '_galleries':
                    $album = FooGalleryAlbum::get($post);
                    echo $album->gallery_count();
                    break;
                case FOOGALLERY_CPT_ALBUM . '_shortcode':
                    $album = FooGalleryAlbum::get($post);
                    $shortcode = $album->shortcode();
                    echo '<code data-clipboard-text="' . esc_attr($shortcode) . '"
					  title="' . esc_attr__('Click to copy to your clipboard', 'foogallery') . '"
					  class="foogallery-shortcode">' . $shortcode . '</code>';
                    $this->include_clipboard_script = true;
                    break;
            }
        }
Ejemplo n.º 2
0
 public function get_album($post)
 {
     if (!isset($this->_album)) {
         $this->_album = FooGalleryAlbum::get($post);
     }
     return $this->_album;
 }
Ejemplo n.º 3
0
 function album_custom_column_content($column)
 {
     global $post;
     switch ($column) {
         case FOOGALLERY_CPT_ALBUM . '_template':
             $album = FooGalleryAlbum::get($post);
             $template = $album->album_template_details();
             if (false !== $template) {
                 echo $template['name'];
             }
             break;
         case FOOGALLERY_CPT_ALBUM . '_galleries':
             $album = FooGalleryAlbum::get($post);
             echo $album->gallery_count();
             break;
         case FOOGALLERY_CPT_ALBUM . '_shortcode':
             $album = FooGalleryAlbum::get($post);
             $shortcode = $album->shortcode();
             echo '<input type="text" readonly="readonly" size="' . strlen($shortcode) . '" value="' . esc_attr($shortcode) . '" class="foogallery-shortcode" />';
             $this->include_clipboard_script = true;
             break;
     }
 }
 /**
  * load the gallery based on either the id or slug, passed in via arguments
  *
  * @param $args array       Arguments passed in from the shortcode
  *
  * @return bool|FooGallery  The gallery object we want to render
  */
 function find_album($args)
 {
     $id = intval($this->get_arg($args, 'id'), 0);
     if ($id > 0) {
         //load album by ID
         return FooGalleryAlbum::get_by_id($id);
     } else {
         //take into account the cases where id is passed in via the 'album' attribute
         $album = $this->get_arg('album', 0);
         if (intval($album) > 0) {
             //we have an id, so load
             return FooGalleryAlbum::get_by_id(intval($album));
         }
         //we are dealing with a slug
         return FooGalleryAlbum::get_by_slug($album);
     }
 }
        function render_album_import_form($albums = false)
        {
            if (false === $albums) {
                $albums = $this->get_albums();
            }
            $has_imports = get_option(self::NEXTGEN_OPTION_IMPORT_PROGRESS_ALBUM);
            ?>
			<table class="wp-list-table widefat" cellspacing="0">
				<thead>
				<tr>
					<th scope="col" class="manage-column">
						<span><?php 
            _e('NextGen Album', 'foogallery');
            ?>
</span>
					</th>
					<th scope="col" class="manage-column">
						<span><?php 
            _e('Album Name', 'foogallery');
            ?>
</span>
					</th>
					<th scope="col" class="manage-column">
						<span><?php 
            _e('NextGen Galleries', 'foogallery');
            ?>
</span>
					</th>
					<th scope="col" class="manage-column">
						<span><?php 
            _e('Import Options', 'foogallery');
            ?>
</span>
					</th>
				</tr>
				</thead>
				<tbody>
				<?php 
            $counter = 0;
            foreach ($albums as $album) {
                $counter++;
                $progress = $this->get_import_progress_for_album($album->id);
                $done = $progress->is_completed();
                $edit_link = '';
                $galleries = $this->nextgen_unserialize($album->sortorder);
                $foogallery_album = false;
                if ($progress->foogallery_album_id > 0) {
                    $foogallery_album = FooGalleryAlbum::get_by_id($progress->foogallery_album_id);
                    if ($foogallery_album) {
                        $edit_link = '<a href="' . admin_url('post.php?post=' . $progress->foogallery_album_id . '&action=edit') . '">' . $foogallery_album->name . '</a>';
                    } else {
                        $done = false;
                    }
                }
                ?>
					<tr class="<?php 
                echo $counter % 2 === 0 ? 'alternate' : '';
                ?>
">
						<td>
							<?php 
                echo $album->name;
                ?>
							<input type="hidden" class="foogallery-album-id" value="<?php 
                echo $album->id;
                ?>
">
						</td>
						<td>
							<?php 
                if ($foogallery_album) {
                    echo $edit_link;
                } else {
                    ?>
								<input class="foogallery-album-name" value="<?php 
                    echo $album->name;
                    ?>
">
							<?php 
                }
                ?>
						</td>
						<td>
							<ul class="ul-disc" style="margin: 0 0 0 20px;">
							<?php 
                $import_gallery_count = 0;
                foreach ($galleries as $gallery_id) {
                    if ('a' === substr($gallery_id, 0, 1)) {
                        //we are dealing with an album inside the album
                        $nested_album = $this->get_album(substr($gallery_id, 1));
                        if ($nested_album) {
                            echo '<li>';
                            echo __('[Album] ', 'foogallery');
                            echo ' <span style="text-decoration:line-through">';
                            echo $nested_album->name;
                            echo '</span>';
                            echo ' (<span class="nextgen-import-progress-' . FooGallery_NextGen_Import_Progress::PROGRESS_ERROR . '">';
                            echo __('nested albums not supported', 'foogallery');
                            echo '</span>)</li>';
                        }
                    } else {
                        $nextgen_gallery = $this->get_gallery($gallery_id);
                        echo '<li>';
                        $gallery_progress = $this->get_import_progress($gallery_id);
                        $gallery_completed = $gallery_progress->is_completed();
                        if ($gallery_completed) {
                            $import_gallery_count++;
                        }
                        echo $gallery_completed ? '' : '<span style="text-decoration:line-through">';
                        echo $nextgen_gallery->title;
                        echo $gallery_completed ? '' : '</span>';
                        echo ' (<span class="nextgen-import-progress-' . $gallery_progress->status . '">';
                        echo $gallery_completed ? __('imported', 'foogallery') : __('not imported', 'foogallery');
                        echo '</span>)</li>';
                    }
                }
                ?>
							</ul>
						</td>
						<td>
							<span class="nextgen-import-progress nextgen-import-progress-<?php 
                echo $progress->status;
                ?>
">
								<?php 
                echo $progress->message();
                ?>
							</span>
							<?php 
                echo '<br />';
                if (!$progress->is_completed()) {
                    if ($import_gallery_count > 0) {
                        echo '<input type="submit" class="button button-primary start_album_import" value="Import Album">';
                        echo '<div class="inline" style="width:20px"><span class="spinner"></span></div>';
                        echo '<br />';
                        if ($import_gallery_count === count($galleries)) {
                            _e('All galleries will be linked', 'foogallery');
                        } else {
                            echo sprintf(__('%d/%d galleries will be linked', 'foogallery'), $import_gallery_count, count($galleries));
                            echo '<br />';
                            _e('(Only previously imported galleries can be linked)', 'foogallery');
                        }
                    } else {
                        _e('No galleries imported yet!!', 'foogallery');
                    }
                }
                ?>
						</td>
					</tr>
				<?php 
            }
            ?>
				</tbody>
			</table>
			<?php 
            wp_nonce_field('foogallery_nextgen_album_reset', 'foogallery_nextgen_album_reset', false);
            wp_nonce_field('foogallery_nextgen_album_import', 'foogallery_nextgen_album_import', false);
            if ($has_imports) {
                ?>
				<br />
				<input type="submit" name="foogallery_nextgen_reset_album" class="button reset_album_import" value="<?php 
                _e('Reset All Album Imports', 'foogallery');
                ?>
">
			<?php 
            }
        }