Example #1
0
					<strong><?php 
_e("Add Catalog Item's To Gallery", 'catablog');
?>
</strong>
				</h3>
				
				<div class="catablog-modal-body">
					
					
					<select name="gallery_id" id="catablog_gallery_id">
						<option value="-1">- <?php 
_e("Select a Gallery", "catablog");
?>
</option>
						<?php 
foreach (CataBlogGallery::getGalleries('title') as $gallery) {
    ?>
							<?php 
    echo "<option value='{$gallery->getId()}'>{$gallery->getTitle()}</option>";
    ?>
						<?php 
}
?>
					</select>
					
					<?php 
wp_nonce_field('catablog_append_gallery', '_catablog_append_gallery_nonce', false, true);
?>
					
					<input type="submit" name="save" value="<?php 
_e("Add To Gallery", 'catablog');
 /**
  * Get a collection of catalog galleries from the database. May
  * possibly return an empty array.
  *
  * @param string $sort The database field used to sort the collection. Possible values are 'title', 'order', 'date' or 'random'.
  * @param string $order The order the collection should be returned in. Possible values are 'asc' or 'desc'.
  * @param integer $offset The start ordinal of the collection, or number of catalog items to skip over.
  * @param integer $limit The maximum amount of catalog items allowed in the collection.
  * @return array An array of CataBlogGallery objects
  */
 public static function getGalleries($sort = 'menu_order', $order = 'asc', $offset = 0, $limit = -1)
 {
     $galleries = array();
     $cata = new CataBlogGallery();
     $params = array('post_type' => $cata->getCustomPostGalleryName(), 'orderby' => $sort, 'order' => $order, 'offset' => $offset, 'numberposts' => $limit);
     $posts = get_posts($params);
     // return an array of CataBlogGallery objects
     foreach ($posts as $post) {
         $gallery = new CataBlogGallery();
         $gallery->id = $post->ID;
         $gallery->item_ids = unserialize($post->post_content);
         $gallery->title = $post->post_title;
         $gallery->description = $post->post_excerpt;
         $gallery->date = $post->post_date;
         $gallery->_post_name = $post->post_name;
         $galleries[] = $gallery;
     }
     return $galleries;
 }
Example #3
0
 public function frontend_shortcode_catablog_gallery($atts)
 {
     $shortcode_params = array('id' => false, 'template' => false, 'limit' => -1, 'navigation' => true);
     extract(shortcode_atts($shortcode_params, $atts));
     if ($id === false) {
         return __("You must use the id attribute in the catablog_gallery Shortcode", "catablog");
     }
     // disable navigation if it is present in the turn off words array
     $turn_off_nav_words = array(false, 'no', 'off', 'disable', 'disabled', 'false');
     $navigation = in_array(strtolower($navigation), $turn_off_nav_words) ? false : true;
     // initialize pagination variables
     $paged = 1;
     $total = 0;
     if (isset($_REQUEST[$this->pagination_query_label])) {
         $paged = is_numeric($_REQUEST[$this->pagination_query_label]) ? intval($_REQUEST[$this->pagination_query_label]) : 1;
     }
     $offset = ($paged - 1) * $limit;
     // !! NOTE: Eventually $offset and $limit should be used here for better db performance
     $gallery = CataBlogGallery::getGallery($id);
     if (!is_object($gallery)) {
         return sprintf(__("Could not find a CataBlog Gallery with id %s", "catablog"), $id);
     }
     $gallery_item_ids = $gallery->getItemIds();
     $gallery_items = $gallery->getCataBlogItems();
     foreach ($gallery_item_ids as $key => $item_id) {
         if (!isset($gallery_items[$item_id])) {
             unset($gallery_item_ids[$key]);
         }
     }
     $total = count($gallery_item_ids);
     if ($limit > 0) {
         $gallery_item_ids = array_slice($gallery_item_ids, $offset, $limit, true);
     }
     ob_start();
     if ($navigation) {
         if ($this->options['nav-location'] != 'bottom') {
             $this->frontend_build_navigation($paged, $limit, $total);
         }
     }
     echo "<div class='catablog-catalog'>";
     foreach ($gallery_item_ids as $item_id) {
         echo $this->frontend_render_catalog_row($gallery_items[$item_id], $template);
     }
     echo "</div>";
     if ($navigation) {
         if ($this->options['nav-location'] != 'top') {
             $this->frontend_build_navigation($paged, $limit, $total);
         }
     }
     return ob_get_clean();
 }