Example #1
0
function mpp_setup_gallery_nav()
{
    //only add on single gallery
    if (!mpp_is_single_gallery()) {
        return;
    }
    $gallery = mpp_get_current_gallery();
    $url = '';
    if ($gallery) {
        $url = mpp_get_gallery_permalink($gallery);
    }
    //only add view/edit/dele links on the single mgallery view
    mpp_add_gallery_nav_item(array('label' => __('View', 'mediapress'), 'url' => $url, 'action' => 'view', 'slug' => 'view'));
    $user_id = get_current_user_id();
    if (mpp_user_can_edit_gallery($gallery->id, $user_id)) {
        mpp_add_gallery_nav_item(array('label' => __('Edit Media', 'mediapress'), 'url' => mpp_get_gallery_edit_media_url($gallery), 'action' => 'edit', 'slug' => 'edit'));
    }
    if (mpp_user_can_upload($gallery->component, $gallery->component_id)) {
        mpp_add_gallery_nav_item(array('label' => __('Add Media', 'mediapress'), 'url' => mpp_get_gallery_add_media_url($gallery), 'action' => 'add', 'slug' => 'add'));
    }
    if (mpp_user_can_edit_gallery($gallery->id, $user_id)) {
        mpp_add_gallery_nav_item(array('label' => __('Reorder', 'mediapress'), 'url' => mpp_get_gallery_reorder_media_url($gallery), 'action' => 'reorder', 'slug' => 'reorder'));
        mpp_add_gallery_nav_item(array('label' => __('Edit Details', 'mediapress'), 'url' => mpp_get_gallery_settings_url($gallery), 'action' => 'settings', 'slug' => 'settings'));
    }
    if (mpp_user_can_delete_gallery($gallery->id)) {
        mpp_add_gallery_nav_item(array('label' => __('Delete', 'mediapress'), 'url' => mpp_get_gallery_delete_url($gallery), 'action' => 'delete', 'slug' => 'delete'));
    }
}
Example #2
0
function mpp_filter_body_class($classes, $class)
{
    $new_classes = array();
    $component = mpp_get_current_component();
    //if not mediapress pages, return
    if (!mpp_is_gallery_component() && !mpp_is_component_gallery()) {
        return $classes;
    }
    //ok, It must be mpp pages
    $new_classes[] = 'mpp-page';
    //for all mediapress pages
    //if it is a directory page
    if (mpp_is_gallery_directory()) {
        $new_classes[] = 'mpp-page-directory';
    } elseif (mpp_is_gallery_component() || mpp_is_component_gallery()) {
        //we are on user gallery  page or a component gallery page
        //append class mpp-page-members or mpp-page-groups or mpp-page-events etc depending on the current associated component
        $new_classes[] = 'mpp-page-' . $component;
        if (mpp_is_media_management()) {
            //is it edit media?
            $new_classes[] = 'mpp-page-media-management';
            $new_classes[] = 'mpp-page-media-management-' . mpp_get_media_type();
            //mpp-photo-management, mpp-audio-management
            $new_classes[] = 'mpp-page-media-manage-action-' . mediapress()->get_edit_action();
            //mpp-photo-management, mpp-audio-management
        } elseif (mpp_is_single_media()) {
            //is it single media
            $new_classes[] = 'mpp-page-media-single';
            $new_classes[] = 'mpp-page-media-single-' . mpp_get_media_type();
        } elseif (mpp_is_gallery_management()) {
            //id gallery management?
            $new_classes[] = 'mpp-page-gallery-management';
            $new_classes[] = 'mpp-page-gallery-management-' . mpp_get_gallery_type();
            $new_classes[] = 'mpp-page-gallery-manage-action-' . mediapress()->get_edit_action();
        } elseif (mpp_is_single_gallery()) {
            //is singe gallery
            $new_classes[] = 'mpp-page-single-gallery';
            $new_classes[] = 'mpp-page-single-gallery-' . mpp_get_gallery_type();
            $new_classes[] = 'mpp-page-single-gallery-' . mpp_get_gallery_status();
        } else {
            //it is the gallery listing page of the component
            $new_classes[] = 'mpp-page-gallery-list';
            //home could have been a better name
            $new_classes[] = 'mpp-page-gallery-list-' . $component;
            //home could have been a better name
        }
    }
    if (!empty($new_classes)) {
        $classes = array_merge($classes, $new_classes);
    }
    return $classes;
}
Example #3
0
 public function switch_view()
 {
     //single gallery
     //single media
     //edit gallery
     //edit media
     if (!mpp_is_user_gallery_component()) {
         return;
     }
     if (mpp_is_media_management()) {
         $this->manage_media();
     } elseif (mpp_is_single_media()) {
         $this->single_media();
     } elseif (mpp_is_single_gallery()) {
         //mpp single gallery will be true for the single gallery/edit both
         if (mpp_is_gallery_management()) {
             $this->manage_gallery();
         } else {
             $this->single_gallery();
         }
     }
 }
function mpp_list_comments($args, $comments = null)
{
    $post_id = 0;
    if (!isset($args['post_id'])) {
        if (mpp_is_single_media()) {
            $post_id = mpp_get_current_media_id();
        } elseif (mpp_is_single_gallery()) {
            $post_id = mpp_get_current_gallery_id();
        }
    } else {
        $post_id = $args['post_id'];
    }
    if ($post_id) {
        $comments = get_comments(array('post_id' => $post_id));
    }
    wp_list_comments($args, $comments);
}
 public function context_menu_edit()
 {
     if (!mpp_is_single_gallery()) {
         return;
     }
     if (mpp_is_gallery_management() || mpp_is_media_management()) {
         return;
     }
     if (!mpp_user_can_edit_gallery(mpp_get_current_gallery_id())) {
         return;
     }
     $links = '';
     if (mpp_is_single_media()) {
         $url = mpp_get_media_edit_url();
         $links .= sprintf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', $url, _x('Edit media', 'Profile context menu rel', 'mediapress'), _x('Edit', 'Profile context menu media edit label', 'mediapress'));
     } else {
         $url = mpp_get_gallery_edit_media_url(mpp_get_current_gallery());
         //bulk edit media url
         $links .= sprintf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', $url, _x('Edit Gallery', 'Profile context menu rel attribute', 'mediapress'), _x('Edit', 'Profile contextual edit gallery menu label', 'mediapress'));
         $links .= sprintf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', mpp_get_gallery_add_media_url(mpp_get_current_gallery()), _x('Add Media', 'Profile context menu rel attribute', 'mediapress'), _x('Add Media', 'Profile contextual add media  menu label', 'mediapress'));
     }
     echo $links;
 }
Example #6
0
 public function add_js_data()
 {
     $settings = array('enable_activity_lightbox' => mpp_get_option('enable_activity_lightbox'));
     $active_types = mpp_get_active_types();
     $extensions = $type_erros = array();
     foreach ($active_types as $type => $object) {
         $type_extensions = mpp_get_allowed_file_extensions_as_string($type, ',');
         $extensions[$type] = array('title' => sprintf('Select %s', ucwords($type)), 'extensions' => $type_extensions);
         $readable_extensions = mpp_get_allowed_file_extensions_as_string($type, ', ');
         $type_erros[$type] = sprintf(_x('This file type is not allowed. Allowed file types are: %s', 'type error message', 'mediapress'), $readable_extensions);
         $allowed_type_messages[$type] = sprintf(_x(' Please only select : %s', 'type error message', 'mediapress'), $readable_extensions);
     }
     $settings['types'] = $extensions;
     $settings['type_errors'] = $type_erros;
     $settings['allowed_type_messages'] = $allowed_type_messages;
     if (mpp_is_single_gallery()) {
         $settings['current_type'] = mpp_get_current_gallery()->type;
     }
     $settings['loader_src'] = mpp_get_asset_url('assets/images/loader.gif', 'mpp-loader');
     $settings = apply_filters('mpp_localizable_data', $settings);
     wp_localize_script('mpp_core', '_mppData', $settings);
     //_mppData
 }
Example #7
0
mpp_gallery_breadcrumb();
?>
</div>
	<?php 
if (is_super_admin()) {
    mpp_display_space_usage();
}
//main file loaded by MediaPress
//it loads the requested file
if (mpp_is_gallery_create()) {
    $template = 'gallery/create.php';
} elseif (mpp_is_gallery_management()) {
    $template = 'sitewide/gallery/manage.php';
} elseif (mpp_is_media_management()) {
    $template = 'sitewide/media/manage.php';
} elseif (mpp_is_single_media()) {
    $template = 'sitewide/media/single.php';
} elseif (mpp_is_single_gallery()) {
    $template = 'sitewide/gallery/single.php';
} elseif (mpp_is_gallery_home()) {
    $template = 'gallery/loop-gallery.php';
} else {
    $template = 'gallery/404.php';
    //not found
}
$template = apply_filters('mpp_get_sitewide_gallery_template', $template);
mpp_get_template($template);
setup_postdata(mpp_get_current_gallery());
?>
 
</div>  <!-- end of mpp-container -->
Example #8
0
 public function context_menu_edit()
 {
     if (mpp_is_gallery_management() || mpp_is_media_management()) {
         return;
     }
     if (!mpp_is_single_gallery()) {
         return;
     }
     if (!mpp_user_can_edit_gallery(mpp_get_current_gallery_id())) {
         return;
     }
     if (mpp_is_single_media()) {
         $url = mpp_get_media_edit_url();
     } else {
         $url = mpp_get_gallery_edit_media_url(mpp_get_current_gallery());
     }
     //bulk edit media url
     printf('<li><a href="%1$s" title ="%2$s"> %3$s</a></li>', $url, __('Edit', 'mediapress'), __('Edit', 'mediapress'));
 }
/**
 * Generate/Display breadcrumb 
 * @param array $args
 * @return string|null
 */
function mpp_gallery_breadcrumb($args = null)
{
    $default = array('separator' => '/', 'before' => '', 'after' => '', 'show_home' => false);
    $args = wp_parse_args($args, $default);
    extract($args);
    $crumbs = array();
    $component = mpp_get_current_component();
    $component_id = mpp_get_current_component_id();
    if (mediapress()->is_bp_active() && bp_is_active('groups') && bp_is_group()) {
        $name = bp_get_group_name(groups_get_current_group());
    } elseif (mediapress()->is_bp_active() && bp_is_user()) {
        $name = bp_get_displayed_user_fullname();
    } elseif ($component == 'sitewide') {
        $name = '';
    }
    $my_or_his_gallery = '';
    if ($name) {
        $my_or_his_gallery = sprintf(__("%s's gallery", 'mediapress'), $name);
    }
    if (function_exists('bp_is_my_profile') && bp_is_my_profile()) {
        $my_or_his_gallery = __('Your Galleries', 'mediapress');
    }
    if (mpp_is_media_management()) {
        $crumbs[] = ucwords(mediapress()->get_edit_action());
    }
    if (mpp_is_single_media()) {
        $media = mpp_get_current_media();
        if (mpp_is_media_management()) {
            $crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_media_permalink($media), mpp_get_media_title($media));
        } else {
            $crumbs[] = sprintf('<span>%s</span>', mpp_get_media_title($media));
        }
    }
    if (mpp_is_gallery_management()) {
        $crumbs[] = ucwords(mediapress()->get_edit_action());
    }
    if (mpp_is_single_gallery()) {
        $gallery = mpp_get_current_gallery();
        if (mpp_is_gallery_management() || mpp_is_single_media()) {
            $crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_gallery_permalink($gallery), mpp_get_gallery_title($gallery));
        } else {
            $crumbs[] = sprintf('<span>%s</span>', mpp_get_gallery_title($gallery));
        }
    }
    if ($my_or_his_gallery) {
        $crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_gallery_base_url($component, $component_id), $my_or_his_gallery);
    }
    if (count($crumbs) <= 1 && !$show_home) {
        return;
    }
    $crumbs = array_reverse($crumbs);
    echo join($separator, $crumbs);
}
/**
 * Format activity action for 'mpp_media_upload' activity type.
 *
 * 
 * @param string $action  activity action.
 * @param object $activity Activity object.
 * @return string
 */
function mpp_format_activity_action_media_upload($action, $activity)
{
    $userlink = mpp_get_user_link($activity->user_id);
    $media_ids = array();
    $media_id = 0;
    $media_id = mpp_activity_get_media_id($activity->id);
    if (!$media_id) {
        $media_ids = mpp_activity_get_attached_media_ids($activity->id);
        if (!empty($media_ids)) {
            $media_id = $media_ids[0];
        }
    }
    $gallery_id = mpp_activity_get_gallery_id($activity->id);
    if (!$media_id && !$gallery_id) {
        return $action;
        //not a gallery activity, no need to proceed further
    }
    $media = mpp_get_media($media_id);
    $gallery = mpp_get_gallery($gallery_id);
    if (!$media && !$gallery) {
        return $action;
    }
    $activity_type = mpp_activity_get_activity_type($activity->id);
    //is a type specified
    $skip = false;
    if ($activity_type) {
        if (in_array($activity_type, array('edit_gallery', 'add_media'))) {
            //'create_gallery',
            $skip = true;
        }
    }
    //there us still a chance for improvement, we should dynamically generate the action instead for the above actions too
    if ($skip) {
        return $action;
    }
    if ($activity_type == 'media_upload') {
        $media_count = count($media_ids);
        $media_id = current($media_ids);
        $type = $gallery->type;
        //we need the type plural in case of mult
        $type = _n($type, $type . 's', $media_count);
        //photo vs photos etc
        $action = sprintf(__('%s uploaded %d new %s', 'mediapress'), $userlink, $media_count, $type);
        //allow modules to filter the action and change the message
        $action = apply_filters('mpp_activity_action_media_upload', $action, $activity, $media_id, $media_ids, $gallery);
    } elseif ($activity_type == 'media_comment') {
        if (mpp_is_single_media()) {
            $action = sprintf(__('%s', 'mediapress'), $userlink);
        } else {
            $action = sprintf(__("%s commented on %s's %s", 'mediapress'), $userlink, mpp_get_user_link($media->user_id), $media->type);
            //brajesh singh commented on @mercime's photo
        }
    } elseif ($activity_type == 'gallery_comment') {
        if (mpp_is_single_gallery()) {
            $action = sprintf('%s', $userlink);
        } else {
            $action = sprintf(__("%s commented on %s's <a href='%s'>%s gallery</a>", 'mediapress'), $userlink, mpp_get_user_link($gallery->user_id), mpp_get_gallery_permalink($gallery), $gallery->type);
        }
    } elseif ($activity_type == 'create_gallery') {
        $action = sprintf(__('%s created a %s <a href="%s">gallery</a>', 'mediapress'), $userlink, $gallery->type, mpp_get_gallery_permalink($gallery));
    } else {
        $action = sprintf(__('%s', 'mediapress'), $userlink);
    }
    return apply_filters('mpp_format_activity_action_media_upload', $action, $activity, $media_id, $media_ids);
}
Example #11
0
			<?php 
if (bp_is_active('groups') && bp_is_group()) {
    ?>

				<input type="hidden" id="mpp-whats-new-post-object" name="whats-new-post-object" value="groups" />
				<input type="hidden" id="mpp-whats-new-post-in" name="whats-new-post-in" value="<?php 
    bp_group_id(groups_get_current_group());
    ?>
" />

			<?php 
}
?>
				<?php 
if (mpp_is_single_gallery() && !mpp_is_single_media()) {
    ?>
					<input type="hidden" name='mpp-item-id' id="mpp-item-id" value="<?php 
    echo mpp_get_current_gallery_id();
    ?>
" />
					<input type="hidden" name='mpp-activity-type' id="mpp-activity-type" value="gallery" />
				<?php 
} else {
    ?>
						
					<input type="hidden" name='mpp-item-id' id="mpp-item-id" value="<?php 
    echo mpp_get_current_media_id();
    ?>
" />
					<input type="hidden" name='mpp-activity-type' id="mpp-activity-type" value="media" />
Example #12
0
/**
 * Format activity action for 'mpp_media_upload' activity type.
 *
 * 
 * @param string $action  activity action.
 * @param object $activity Activity object.
 * @return string
 */
function mpp_format_activity_action_media_upload($action, $activity)
{
    $userlink = bp_core_get_userlink($activity->user_id);
    $media_ids = array();
    //this could be a comment
    //or a media comment
    //or a gallery comment
    //or an activity upload
    $media_id = mpp_activity_get_media_id($activity->id);
    $gallery_id = mpp_activity_get_gallery_id($activity->id);
    if (!$media_id && !$gallery_id) {
        return $action;
    }
    //not a gallery activity, no need to proceed further
    $type = mpp_activity_get_activity_type($activity->id);
    //is a type specified
    $skip = false;
    if ($type) {
        if (in_array($type, array('create_gallery', 'edit_gallery', 'add_media'))) {
            $skip = true;
        }
    }
    if (!$skip && $media_id) {
        $media = mpp_get_media($media_id);
        //this is an activity comment on single media
        if (mpp_is_single_media()) {
            $action = sprintf(__('%s', 'mpp'), $userlink);
        } else {
            $action = sprintf(__("%s commented on %s's %s", 'mpp'), $userlink, bp_core_get_userlink($media->user_id), $media->type);
            //brajesh singh commented on @mercime's photo
        }
    } elseif (!$skip && $gallery_id) {
        $gallery = mpp_get_gallery($gallery_id);
        //check for the uploaded media
        $media_ids = mpp_activity_get_attached_media_ids($activity->id);
        //this will never fire but let us be defensive
        if (empty($media_ids)) {
            //this is gallery comment
            if (mpp_is_single_gallery()) {
                $action = sprintf('%s', $userlink);
            } else {
                $action = sprintf(__("%s commented on %s's <a href='%s'>%s gallery</a>", 'mpp'), $userlink, bp_core_get_userlink($gallery->user_id), mpp_get_gallery_permalink($gallery), $gallery->type);
            }
        } else {
            //we will always be here
            $media_count = count($media_ids);
            $media_id = current($media_ids);
            $type = $gallery->type;
            //we need the type plural in case of mult
            $type = _n($type, $type . 's', $media_count);
            //photo vs photos etc
            $action = sprintf(__('%s uploaded %d new %s', 'mpp'), $userlink, $media_count, $type);
            //allow modules to filter the action and change the message
            $action = apply_filters('mpp_activity_action_media_upload', $action, $activity, $media_id, $media_ids, $gallery);
        }
    }
    return apply_filters('mpp_format_activity_action_media_upload', $action, $activity, $media_id, $media_ids);
}