public function setup_nav($main = array(), $sub = array())
 {
     $bp = buddypress();
     $component = 'members';
     $component_id = mpp_get_current_component_id();
     if (!mpp_is_enabled($component, $component_id)) {
         //allow to disable user galleries in case they don't want it
         return false;
     }
     $view_helper = MPP_Gallery_Screens::get_instance();
     // Add 'Gallery' to the user's main navigation
     $main_nav = array('name' => sprintf(__('Gallery <span>%d</span>', 'mediapress'), mpp_get_total_gallery_for_user()), 'slug' => $this->slug, 'position' => 86, 'screen_function' => array($view_helper, 'user_galleries'), 'default_subnav_slug' => 'my-galleries', 'item_css_id' => $this->id);
     if (bp_is_user()) {
         $user_domain = bp_displayed_user_domain();
     } else {
         $user_domain = bp_loggedin_user_domain();
     }
     $gallery_link = trailingslashit($user_domain . $this->slug);
     //with a trailing slash
     // Add the My Gallery nav item
     $sub_nav[] = array('name' => __('My Gallery', 'mediapress'), 'slug' => 'my-galleries', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 10, 'item_css_id' => 'gallery-my-gallery');
     if (mpp_user_can_create_gallery($component, get_current_user_id())) {
         // Add the Create gallery link to gallery nav
         $sub_nav[] = array('name' => __('Create a Gallery', 'mediapress'), 'slug' => 'create', 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'user_has_access' => bp_is_my_profile(), 'position' => 20);
     }
     if (mpp_component_has_type_filters_enabled($component, $component_id)) {
         $i = 10;
         $supported_types = mpp_component_get_supported_types($component);
         foreach ($supported_types as $type) {
             if (!mpp_is_active_type($type)) {
                 continue;
             }
             $type_object = mpp_get_type_object($type);
             $sub_nav[] = array('name' => $type_object->label, 'slug' => 'type/' . $type, 'parent_url' => $gallery_link, 'parent_slug' => $this->slug, 'screen_function' => array($view_helper, 'my_galleries'), 'position' => 20 + $i);
             $i = $i + 10;
             //increment the position
         }
     }
     // Add the Upload link to gallery nav
     /*$sub_nav[] = array(
           'name'				=> __( 'Upload', 'mediapress'),
           'slug'				=> 'upload',
           'parent_url'		=> $gallery_link,
           'parent_slug'		=> $this->slug,
           'screen_function'	=> array( $view_helper, 'upload_media' ),
           'user_has_access'	=> bp_is_my_profile(),
           'position'			=> 30
       );*/
     parent::setup_nav($main_nav, $sub_nav);
     //disallow these names in various lists
     //we have yet to implement it
     $this->forbidden_names = apply_filters('mpp_forbidden_names', array('gallery', 'galleries', 'my-gallery', 'create', 'delete', 'upload', 'add', 'edit', 'admin', 'request', 'upload', 'tags', 'audio', 'video', 'photo'));
     //use this to extend the valid status
     $this->valid_status = apply_filters('mpp_valid_gallery_status', array_keys(mpp_get_active_statuses()));
     do_action('mpp_setup_nav');
     // $bp->gallery->current_gallery->user_has_access
 }
Esempio n. 2
0
 public function get_value($options)
 {
     $type = mpp_get_type_object($this->key);
     $allowed_extensions = $type->get_allowed_extensions();
     if (empty($allowed_extensions)) {
         $allowed_extensions = $type->get_registered_extensions();
     }
     return join(',', $allowed_extensions);
 }
/**
 * Get allowed file extensions for this type as array
 * 
 * @param type $type audio|photo|video etc
 * @return array( 'jpg', 'gif', ..)//allowed extensions for a given type
 */
function mpp_get_allowed_file_extensions($type)
{
    if (!mpp_is_registered_type($type)) {
        //should we only do it for active types?
        return array();
    }
    $type_object = mpp_get_type_object($type);
    return $type_object->get_allowed_extensions();
}
Esempio n. 4
0
/**
 * Get singular name for the given type
 * 
 * @param mixed|int $object gallery or media object or ID
 * @return string label for the gallery, media type e.g (Audio| Video| Photo)
 */
function mpp_get_object_type_singular_name($object)
{
    $type_id = mpp_get_object_type_term_id($object);
    //now get the slug for this status
    $type = mpp_get_type_object($type_id);
    return $type->singular_name;
}
    public function generate_meta_box($post)
    {
        $col = 0;
        $row = 0;
        $taxonomies = mpp_get_all_taxonomies_info();
        ?>
		<div id="mpp-taxonomy-metabox" class="categorydiv mpp-taxonomy-list">
			<ul>
				<?php 
        foreach ($taxonomies as $taxonomy => $info) {
            ?>
					<li class="mpp-taxonomy mpp-taxonomy-<?php 
            echo $taxonomy;
            ?>
">
						<?php 
            $name = 'mpp-gallery-' . str_replace('gallery-', '', $taxonomy);
            // echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
            $tax = get_taxonomy($taxonomy);
            //tax_input[milestone][]
            $selected = wp_get_object_terms($post->ID, $taxonomy, array('fields' => 'ids'));
            $selected = array_pop($selected);
            ?>

							<label><?php 
            echo str_replace('Gallery', '', $tax->labels->singular_name);
            ?>
</label> 
						<?php 
            if ($taxonomy == mpp_get_type_taxname()) {
                //in case of type taxonomy, we need to show the details and not allow editing
                if (!$selected) {
                    $selected = 'N/A';
                } else {
                    $type = mpp_get_type_object($selected);
                    if ($type) {
                        $selected = $type->label;
                    }
                }
                echo "<strong>{$selected}</strong>";
                echo "</li>";
                continue;
            }
            ?>
						<?php 
            wp_dropdown_categories(array('taxonomy' => $taxonomy, 'hide_empty' => false, 'name' => $name, 'id' => 'mpp-tax-' . $taxonomy, 'selected' => $selected, 'show_option_all' => sprintf('Choose %s', $tax->labels->singular_name)));
            ?>
					</li>

					<?php 
        }
        ?>

			</ul> 
			<input type='hidden' name="mpp-gallery-component-id" value="<?php 
        echo $this->get_component_id($post->ID);
        ?>
" />
		</div>    




	<?php 
    }