예제 #1
0
파일: start.php 프로젝트: iionly/tidypics
/**
 * Tidypics plugin initialization
 */
function tidypics_init()
{
    // Register libraries
    $base_dir = elgg_get_plugins_path() . 'tidypics/lib';
    elgg_register_library('tidypics:core', "{$base_dir}/tidypics.php");
    elgg_register_library('tidypics:upload', "{$base_dir}/upload.php");
    elgg_register_library('tidypics:resize', "{$base_dir}/resize.php");
    elgg_register_library('tidypics:exif', "{$base_dir}/exif.php");
    elgg_load_library('tidypics:core');
    // Register an ajax view that allows selection of album to upload images to
    elgg_register_ajax_view('photos/selectalbum');
    // Register an ajax view for the broken images cleanup routine
    elgg_register_ajax_view('photos/broken_images_delete_log');
    // Set up site menu
    $site_menu_links_to = elgg_get_plugin_setting('site_menu_link', 'tidypics');
    if ($site_menu_links_to == 'albums') {
        elgg_register_menu_item('site', array('name' => 'photos', 'href' => 'photos/all', 'text' => elgg_echo('photos')));
    } else {
        elgg_register_menu_item('site', array('name' => 'photos', 'href' => 'photos/siteimagesall', 'text' => elgg_echo('photos')));
    }
    // Register a page handler so we can have nice URLs
    elgg_register_page_handler('photos', 'tidypics_page_handler');
    // Extend CSS
    elgg_extend_view('css/elgg', 'photos/css');
    elgg_extend_view('css/admin', 'photos/css');
    // Register the JavaScript libs
    elgg_register_js('tidypics:slideshow', elgg_get_simplecache_url('tidypics/js/PicLensLite/piclens.js'), 'head');
    elgg_register_js('jquery.plupload-tp', elgg_get_simplecache_url('tidypics/js/plupload/plupload.full.min.js'), 'footer');
    elgg_register_js('jquery.plupload.ui-tp', elgg_get_simplecache_url('tidypics/js/plupload/jquery.ui.plupload/jquery.ui.plupload.min.js'), 'footer');
    $plupload_language = get_plugload_language();
    elgg_register_js('jquery.plupload.ui.lang-tp', elgg_get_simplecache_url('tidypics/js/plupload/i18n/' . $plupload_language . '.js'), 'footer');
    elgg_register_css('jquery.plupload.jqueryui-theme', elgg_get_simplecache_url('tidypics/css/jqueryui-theme.css'));
    elgg_register_css('jquery.plupload.ui', elgg_get_simplecache_url('tidypics/css/plupload/css/jquery.ui.plupload.css'));
    // Add photos link to owner block/hover menus
    elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tidypics_owner_block_menu');
    // Add admin menu item
    elgg_register_admin_menu_item('configure', 'photos', 'settings');
    // Register for search
    elgg_register_entity_type('object', 'image');
    elgg_register_entity_type('object', 'album');
    elgg_register_entity_type('object', 'tidypics_batch');
    // Override search for tidypics_batch subtype to not return any results
    elgg_register_plugin_hook_handler('search', 'object:tidypics_batch', 'tidypics_batch_no_search_results');
    // Register for the entity menu
    elgg_register_plugin_hook_handler('register', 'menu:entity', 'tidypics_entity_menu_setup');
    // Register group options
    add_group_tool_option('photos', elgg_echo('tidypics:enablephotos'), true);
    elgg_extend_view('groups/tool_latest', 'photos/group_module');
    add_group_tool_option('tp_images', elgg_echo('tidypics:enable_group_images'), true);
    elgg_extend_view('groups/tool_latest', 'photos/group_tp_images_module');
    // Register widgets
    elgg_register_widget_type('album_view', elgg_echo("tidypics:widget:albums"), elgg_echo("tidypics:widget:album_descr"), array('profile'));
    elgg_register_widget_type('latest_photos', elgg_echo("tidypics:widget:latest"), elgg_echo("tidypics:widget:latest_descr"), array('profile'));
    if (elgg_is_active_plugin('widget_manager')) {
        //add index widgets for Widget Manager plugin
        elgg_register_widget_type('index_latest_photos', elgg_echo("tidypics:mostrecent"), elgg_echo('tidypics:mostrecent:description'), array('index'));
        elgg_register_widget_type('index_latest_albums', elgg_echo("tidypics:albums_mostrecent"), elgg_echo('tidypics:albums_mostrecent:description'), array('index'));
        //add groups widgets for Widget Manager plugin
        elgg_register_widget_type('groups_latest_photos', elgg_echo("tidypics:mostrecent"), elgg_echo('tidypics:mostrecent:description'), array('groups'));
        elgg_register_widget_type('groups_latest_albums', elgg_echo("tidypics:albums_mostrecent"), elgg_echo('tidypics:albums_mostrecent:description'), array('groups'));
        //register title urls for widgets
        elgg_register_plugin_hook_handler("entity:url", "object", "tidypics_widget_urls");
        // handle the availability of the Tidypics group widgets
        elgg_register_plugin_hook_handler("group_tool_widgets", "widget_manager", "tidypics_tool_widgets_handler");
    }
    // RSS extensions for embedded media
    elgg_extend_view('extensions/xmlns', 'extensions/photos/xmlns');
    // allow group members add photos to group albums
    elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'tidypics_group_permission_override');
    elgg_register_plugin_hook_handler('permissions_check:metadata', 'object', 'tidypics_group_permission_override');
    // notifications
    elgg_register_notification_event('object', 'album', array('album_first', 'album_more'));
    elgg_register_plugin_hook_handler('prepare', 'notification:album_first:object:album', 'tidypics_notify_message');
    elgg_register_plugin_hook_handler('prepare', 'notification:album_more:object:album', 'tidypics_notify_message');
    // allow people in a walled garden to use flash uploader
    elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'tidypics_walled_garden_override');
    // override the default url to view a tidypics_batch object
    elgg_register_plugin_hook_handler('entity:url', 'object', 'tidypics_batch_url_handler');
    // custom layout for comments on tidypics river entries
    elgg_register_plugin_hook_handler('creating', 'river', 'tidypics_comments_handler');
    // allow for liking of albums and images
    elgg_register_plugin_hook_handler('likes:is_likable', 'object:album', 'Elgg\\Values::getTrue');
    elgg_register_plugin_hook_handler('likes:is_likable', 'object:image', 'Elgg\\Values::getTrue');
    // Register actions
    $base_dir = elgg_get_plugins_path() . 'tidypics/actions/photos';
    elgg_register_action("photos/delete", "{$base_dir}/delete.php");
    elgg_register_action("photos/album/save", "{$base_dir}/album/save.php");
    elgg_register_action("photos/album/sort", "{$base_dir}/album/sort.php");
    elgg_register_action("photos/album/set_cover", "{$base_dir}/album/set_cover.php");
    elgg_register_action("photos/image/upload", "{$base_dir}/image/upload.php");
    elgg_register_action("photos/image/save", "{$base_dir}/image/save.php");
    elgg_register_action("photos/image/ajax_upload", "{$base_dir}/image/ajax_upload.php", 'logged_in');
    elgg_register_action("photos/image/ajax_upload_complete", "{$base_dir}/image/ajax_upload_complete.php", 'logged_in');
    elgg_register_action("photos/image/tag", "{$base_dir}/image/tag.php");
    elgg_register_action("photos/image/untag", "{$base_dir}/image/untag.php");
    elgg_register_action("photos/batch/edit", "{$base_dir}/batch/edit.php");
    elgg_register_action("photos/admin/settings", "{$base_dir}/admin/settings.php", 'admin');
    elgg_register_action("photos/admin/create_thumbnails", "{$base_dir}/admin/create_thumbnails.php", 'admin');
    elgg_register_action("photos/admin/resize_thumbnails", "{$base_dir}/admin/resize_thumbnails.php", 'admin');
    elgg_register_action("photos/admin/delete_image", "{$base_dir}/admin/delete_image.php", 'admin');
    elgg_register_action("photos/admin/upgrade", "{$base_dir}/admin/upgrade.php", 'admin');
    elgg_register_action("photos/admin/broken_images", "{$base_dir}/admin/broken_images.php", 'admin');
    elgg_register_action('photos/image/selectalbum', "{$base_dir}/image/selectalbum.php");
}
예제 #2
0
/**
 * Tidypics plugin initialization
 */
function tidypics_init()
{
    // Register libraries
    $base_dir = elgg_get_plugins_path() . 'tidypics/lib';
    elgg_register_library('tidypics:core', "{$base_dir}/tidypics.php");
    elgg_register_library('tidypics:upload', "{$base_dir}/upload.php");
    elgg_register_library('tidypics:resize', "{$base_dir}/resize.php");
    elgg_register_library('tidypics:exif', "{$base_dir}/exif.php");
    elgg_load_library('tidypics:core');
    // Register an ajax view that allows selection of album to upload images to
    elgg_register_ajax_view('photos/selectalbum');
    // 	// Set up site menu
    // 	elgg_register_menu_item('site', array(
    // 		'name' => 'photos',
    // 		'href' => 'photos/siteimagesall',
    // 		'text' => elgg_echo('photos'),
    // 	));
    // Register a page handler so we can have nice URLs
    elgg_register_page_handler('photos', 'tidypics_page_handler');
    // Extend CSS
    elgg_extend_view('css/elgg', 'photos/css');
    elgg_extend_view('css/admin', 'photos/css');
    // Register the JavaScript lib
    $js = elgg_get_simplecache_url('js', 'photos/tidypics');
    elgg_register_simplecache_view('js/photos/tidypics');
    elgg_register_js('tidypics', $js, 'footer');
    $js = elgg_get_simplecache_url('js', 'photos/tagging');
    elgg_register_simplecache_view('js/photos/tagging');
    elgg_register_js('tidypics:tagging', $js, 'footer');
    $js = elgg_get_simplecache_url('js', 'photos/uploading');
    elgg_register_simplecache_view('js/photos/uploading');
    elgg_register_js('tidypics:uploading', $js, 'footer');
    elgg_register_js('tidypics:slideshow', 'mod/tidypics/vendors/PicLensLite/piclens_optimized.js', 'footer');
    elgg_register_js('jquery.plupload-tp', 'mod/tidypics/vendors/plupload/js/plupload.full.min.js', 'footer');
    elgg_register_js('jquery.plupload.ui-tp', 'mod/tidypics/vendors/plupload/js/jquery.plupload.queue/jquery.plupload.queue.min.js', 'footer');
    $plupload_language = get_plugload_language();
    elgg_register_js('jquery.plupload.ui.lang-tp', 'mod/tidypics/vendors/plupload/js/i18n/' . $plupload_language . '.js', 'footer');
    elgg_register_css('jquery.plupload.ui', 'mod/tidypics/vendors/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css');
    // Add photos link to owner block/hover menus
    //elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tidypics_owner_block_menu');
    // Add admin menu item
    elgg_register_admin_menu_item('configure', 'photos', 'settings');
    // Register for search
    elgg_register_entity_type('object', 'image');
    elgg_register_entity_type('object', 'album');
    // Register for the entity menu
    elgg_register_plugin_hook_handler('register', 'menu:entity', 'tidypics_entity_menu_setup');
    // Register group options
    add_group_tool_option('photos', elgg_echo('tidypics:enablephotos'), true);
    elgg_extend_view('groups/tool_latest', 'photos/group_module');
    add_group_tool_option('tp_images', elgg_echo('tidypics:enable_group_images'), true);
    elgg_extend_view('groups/tool_latest', 'photos/group_tp_images_module');
    // Register widgets
    elgg_register_widget_type('album_view', elgg_echo("tidypics:widget:albums"), elgg_echo("tidypics:widget:album_descr"), 'profile');
    elgg_register_widget_type('latest_photos', elgg_echo("tidypics:widget:latest"), elgg_echo("tidypics:widget:latest_descr"), 'profile');
    if (elgg_is_active_plugin('widget_manager')) {
        //add index widgets for Widget Manager plugin
        elgg_register_widget_type('index_latest_photos', elgg_echo("tidypics:mostrecent"), elgg_echo('tidypics:mostrecent:description'), "index");
        elgg_register_widget_type('index_latest_albums', elgg_echo("tidypics:albums_mostrecent"), elgg_echo('tidypics:albums_mostrecent:description'), "index");
        //add groups widgets for Widget Manager plugin
        elgg_register_widget_type('groups_latest_photos', elgg_echo("tidypics:mostrecent"), elgg_echo('tidypics:mostrecent:description'), "groups");
        elgg_register_widget_type('groups_latest_albums', elgg_echo("tidypics:albums_mostrecent"), elgg_echo('tidypics:albums_mostrecent:description'), "groups");
        //register title urls for widgets
        elgg_register_plugin_hook_handler('widget_url', 'widget_manager', "tidypics_widget_urls", 499);
    }
    // RSS extensions for embedded media
    elgg_extend_view('extensions/xmlns', 'extensions/photos/xmlns');
    // allow group members add photos to group albums
    elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'tidypics_group_permission_override');
    elgg_register_plugin_hook_handler('permissions_check:metadata', 'object', 'tidypics_group_permission_override');
    // notifications
    elgg_register_event_handler('notify', 'album', 'object_notifications');
    elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'tidypics_notify_message');
    // allow people in a walled garden to use flash uploader
    elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'tidypics_walled_garden_override');
    // override the default url to view a tidypics_batch object
    elgg_register_entity_url_handler('object', 'tidypics_batch', 'tidypics_batch_url_handler');
    // custom layout for comments on tidypics river entries
    elgg_register_plugin_hook_handler('creating', 'river', 'tidypics_comments_handler');
    // Register actions
    $base_dir = elgg_get_plugins_path() . 'tidypics/actions/photos';
    elgg_register_action("photos/delete", "{$base_dir}/delete.php");
    elgg_register_action("photos/album/save", "{$base_dir}/album/save.php");
    elgg_register_action("photos/album/sort", "{$base_dir}/album/sort.php");
    elgg_register_action("photos/album/set_cover", "{$base_dir}/album/set_cover.php");
    elgg_register_action("photos/album/feature", "{$base_dir}/album/feature.php");
    elgg_register_action("photos/image/upload", "{$base_dir}/image/upload.php");
    elgg_register_action("photos/image/save", "{$base_dir}/image/save.php");
    elgg_register_action("photos/image/ajax_upload", "{$base_dir}/image/ajax_upload.php", 'logged_in');
    elgg_register_action("photos/image/ajax_upload_complete", "{$base_dir}/image/ajax_upload_complete.php", 'logged_in');
    elgg_register_action("photos/image/tag", "{$base_dir}/image/tag.php");
    elgg_register_action("photos/image/untag", "{$base_dir}/image/untag.php");
    elgg_register_action("photos/batch/edit", "{$base_dir}/batch/edit.php");
    elgg_register_action("photos/admin/settings", "{$base_dir}/admin/settings.php", 'admin');
    elgg_register_action("photos/admin/create_thumbnails", "{$base_dir}/admin/create_thumbnails.php", 'admin');
    elgg_register_action("photos/admin/delete_image", "{$base_dir}/admin/delete_image.php", 'admin');
    elgg_register_action("photos/admin/upgrade", "{$base_dir}/admin/upgrade.php", 'admin');
    elgg_register_action('photos/image/selectalbum', "{$base_dir}/image/selectalbum.php");
}