diff --git a/3.0/modules/social_share/controllers/admin_social_share.php b/3.0/modules/social_share/controllers/admin_social_share.php new file mode 100644 index 00000000..7c2aac32 --- /dev/null +++ b/3.0/modules/social_share/controllers/admin_social_share.php @@ -0,0 +1,146 @@ +_get_view(); + } + + public function handler() { + access::verify_csrf(); + + $form = $this->_get_form(); + if ($form->validate()) { + module::set_var("social_share", "facebook_share_enabled", $form->facebook_share_settings->facebook_share_enabled->value); + module::set_var("social_share", "facebook_share_layout", $form->facebook_share_settings->facebook_share_layout->value); + module::set_var("social_share", "facebook_share_link_text", $form->facebook_share_settings->facebook_share_link_text->value); + module::set_var("social_share", "facebook_like_enabled", $form->facebook_like_settings->facebook_like_enabled->value); + module::set_var("social_share", "facebook_like_appId", $form->facebook_like_settings->facebook_like_appId->value); + module::set_var("social_share", "facebook_like_adminId", $form->facebook_like_settings->facebook_like_adminId->value); + module::set_var("social_share", "facebook_like_site_name", $form->facebook_like_settings->facebook_like_site_name->value); + module::set_var("social_share", "facebook_like_code_type", $form->facebook_like_settings->facebook_like_code_type->value); + module::set_var("social_share", "facebook_like_show_faces", $form->facebook_like_settings->facebook_like_show_faces->value, true); + module::set_var("social_share", "facebook_like_send", $form->facebook_like_settings->facebook_like_send->value, true); + module::set_var("social_share", "facebook_like_action", $form->facebook_like_settings->facebook_like_action->value); + module::set_var("social_share", "facebook_like_layout", $form->facebook_like_settings->facebook_like_layout->value); + module::set_var("social_share", "google_enabled", $form->google_settings->google_enabled->value); + module::set_var("social_share", "google_size", $form->google_settings->google_size->value); + module::set_var("social_share", "google_annotation", $form->google_settings->google_annotation->value); + module::set_var("social_share", "twitter_enabled", $form->twitter_settings->twitter_enabled->value); + module::set_var("social_share", "twitter_count_location", $form->twitter_settings->twitter_count_location->value); + module::set_var("social_share", "twitter_size", $form->twitter_settings->twitter_size->value); + message::success(t("Your settings have been saved.")); + url::redirect("admin/social_share"); + } + + print $this->_get_view($form); + } + + private function _get_view($form=null) { + $v = new Admin_View("admin.html"); + $v->content = new View("admin_social_share.html"); + $v->content->form = empty($form) ? $this->_get_form() : $form; + return $v; + } + + private function _get_form() { + $form = new Forge("admin/social_share/handler", "", "post", array("id" => "g-admin-form")); + + $group_facebook_share = $form->group("facebook_share_settings")->label(t("Facebook Share Button Settings")); + $group_facebook_share->checkbox("facebook_share_enabled")->label(t("Display the button")) + ->checked(module::get_var("social_share", "facebook_share_enabled", false) == 1); + $group_facebook_share->dropdown("facebook_share_layout") + ->label(t("The button layout to use")) + ->options(array( "button" => t("Button"), + "icon_link" => t("Icon and Link"), + "icon" => t("Icon"))) + ->selected(module::get_var("social_share", "facebook_share_layout")); + $group_facebook_share->input("facebook_share_link_text")->label(t('Enter the text to place next to the Facebook icon.')) + ->value(module::get_var("social_share", "facebook_share_link_text", "Share")); + + $group_facebook_like = $form->group("facebook_like_settings")->label(t("Facebook Like Button Settings")); + $group_facebook_like->checkbox("facebook_like_enabled")->label(t("Display the button")) + ->checked(module::get_var("social_share", "facebook_like_enabled", false) == 1); + $group_facebook_like->input("facebook_like_appId")->label(t('Enter the appId from FaceBook Create an App. You must get your *own* appID. If you see the number "123456789012345" it is only a demo.
+ Note: www.example.com/ is different than example.com/')) + ->value(module::get_var("social_share", "facebook_like_appId", "123456789012345")) + ->rules("valid_numeric"); + $group_facebook_like->input("facebook_like_adminId")->label(t('Enter yournumeric ID, which you can get as the "Admin" field in Stage 2 of FaceBook Like Button Config. If you see the number "123456789012345" it is only a demo.
')) + ->value(module::get_var("social_share", "facebook_like_adminId", "123456789012345")) + ->rules("valid_numeric"); + $group_facebook_like->input("facebook_like_site_name")->label(t('Enter the site name you want to show on Facebook.')) + ->value(module::get_var("social_share", "facebook_like_site_name", "Gallery")); + $group_facebook_like->dropdown("facebook_like_code_type") + ->label(t("The type of Ccde to display for the button")) + ->options(array( "html5" => t("HTML5 (allows the Send button and better dialogs)"), + "xfbml" => t("XFBML (allows the Send button and better dialogs)"), + "iframe" => t("iFrame"))) + ->selected(module::get_var("social_share", "facebook_like_code_type")); + $group_facebook_like->checkbox("facebook_like_show_faces")->label(t("Display profile photos of the Facebook friends who 'Like' below the Like button (standard layout only).")) + ->checked(module::get_var("social_share", "facebook_like_show_faces")); + $group_facebook_like->checkbox("facebook_like_send")->label(t("Include a Send button with the Like button. This only works with the XFBML version.")) + ->checked(module::get_var("social_share", "facebook_like_send")); + $group_facebook_like->dropdown("facebook_like_action") + ->label(t("Verb to display")) + ->options(array("like" => t("Like"), + "recommend" => t("Recommend"))) + ->selected(module::get_var("social_share", "facebook_like_action")); + $group_facebook_like->dropdown("facebook_like_layout") + ->label(t("Layout style. Determines the size and amount of social context next to the button")) + ->options(array("standard" => t("Standard."), + "button_count" => t("Button count"), + "box_count" => t("Box count"))) + ->selected(module::get_var("social_share", "facebook_like_layout")); + + $group_google = $form->group("google_settings")->label(t("Google+ +1 Button Settings")); + $group_google->checkbox("google_enabled")->label(t("Display the button")) + ->checked(module::get_var("social_share", "google_enabled", false) == 1); + $group_google->dropdown("google_size") + ->label(t("Size of the button")) + ->options(array("standard" => t("Standard (24px)"), + "small" => t("Small (15px)"), + "medium" => t("Medium (20px)"), + "tall" => t("Tall (60px)"))) + ->selected(module::get_var("social_share", "google_size")); + $group_google->dropdown("google_annotation") + ->label(t("Annotation location")) + ->options(array("inline" => t("Inline"), + "bubble" => t("Bubble"), + "none" => t("None"))) + ->selected(module::get_var("social_share", "google_annotation")); + + $group_twitter = $form->group("twitter_settings")->label(t("Twitter Tweet Settings")); + $group_twitter->checkbox("twitter_enabled")->label(t("Display the button")) + ->checked(module::get_var("social_share", "twitter_enabled", false) == 1); + $group_twitter->dropdown("twitter_count_location") + ->label(t("Tweet count location")) + ->options(array("horizontal" => t("Horizontal"), + "vertical" => t("Vertical"), + "none" => t("None"))) + ->selected(module::get_var("social_share", "twitter_count_location")); + $group_twitter->dropdown("twitter_size") + ->label(t("Size of the button. Large does not work with a vertical count location")) + ->options(array("medium" => t("Medium"), + "large" => t("Large"))) + ->selected(module::get_var("social_share", "twitter_size")); + + $form->submit("submit")->value(t("Save")); + return $form; + } +} \ No newline at end of file diff --git a/3.0/modules/social_share/helpers/social_share_block.php b/3.0/modules/social_share/helpers/social_share_block.php new file mode 100644 index 00000000..6f592da3 --- /dev/null +++ b/3.0/modules/social_share/helpers/social_share_block.php @@ -0,0 +1,47 @@ + t("Social Share")); + } + + static function get($block_id, $theme) { + + $block = new Block(); + $block->css_id = "g-social-share"; + $block->title = 'Share With Friends'; + $block->content = ''; + if(module::get_var("social_share", "facebook_share_enabled")){ + $block->content .= new View("facebook_share.html"); + } + if(module::get_var("social_share", "facebook_like_enabled")){ + $block->content .= new View("facebook_like.html"); + } + if(module::get_var("social_share", "google_enabled")){ + $block->content .= new View("google.html"); + } + if(module::get_var("social_share", "twitter_enabled")){ + $block->content .= new View("twitter.html"); + } + + return $block; + } +} \ No newline at end of file diff --git a/3.0/modules/social_share/helpers/social_share_event.php b/3.0/modules/social_share/helpers/social_share_event.php new file mode 100644 index 00000000..c7ed1580 --- /dev/null +++ b/3.0/modules/social_share/helpers/social_share_event.php @@ -0,0 +1,28 @@ +get("settings_menu") + ->append(Menu::factory("link") + ->id("social_share_menu") + ->label(t("Social Share")) + ->url(url::site("admin/social_share"))); + } +} diff --git a/3.0/modules/social_share/helpers/social_share_installer.php b/3.0/modules/social_share/helpers/social_share_installer.php new file mode 100644 index 00000000..153589c1 --- /dev/null +++ b/3.0/modules/social_share/helpers/social_share_installer.php @@ -0,0 +1,56 @@ +item()) { + $item = $theme->item(); + $url = $item->thumb_url(true); + $appId = module::get_var("social_share", "facebook_like_appId"); + $adminId = module::get_var("social_share", "facebook_like_adminId"); + $site_name = module::get_var("social_share", "facebook_like_site_name"); + $selfURL = url::abs_current(true); + return "\t + title\"/> + + + + + "; + } + } +} \ No newline at end of file diff --git a/3.0/modules/social_share/module.info b/3.0/modules/social_share/module.info new file mode 100644 index 00000000..288bdf7d --- /dev/null +++ b/3.0/modules/social_share/module.info @@ -0,0 +1,7 @@ +name = "Social Share" +description = "Adds links to share the page to social media sites in the sidebar." +version = 2 +author_name = "jasonhardin" +author_url = "http://codex.gallery2.org/User:psychoph" +info_url = "http://codex.gallery2.org/Gallery3:Modules:social_share" +discuss_url = "http://gallery.menalto.com/forum_module_social_share" \ No newline at end of file diff --git a/3.0/modules/social_share/views/admin_social_share.html.php b/3.0/modules/social_share/views/admin_social_share.html.php new file mode 100644 index 00000000..e1fd724f --- /dev/null +++ b/3.0/modules/social_share/views/admin_social_share.html.php @@ -0,0 +1,6 @@ + +
+

+ +
+
diff --git a/3.0/modules/social_share/views/facebook_like.html.php b/3.0/modules/social_share/views/facebook_like.html.php new file mode 100644 index 00000000..a831607e --- /dev/null +++ b/3.0/modules/social_share/views/facebook_like.html.php @@ -0,0 +1,75 @@ + + +
+ + + + + +
+ + + + + + + + + +
+ + +
+item()) { + $item = $theme->item(); +} else { + $item = ORM::factory("item", 1); +} +if (access::user_can($guest, "view", $item)) { + $show_like_code = true; +} +?> diff --git a/3.0/modules/social_share/views/facebook_share.html.php b/3.0/modules/social_share/views/facebook_share.html.php new file mode 100644 index 00000000..2637479b --- /dev/null +++ b/3.0/modules/social_share/views/facebook_share.html.php @@ -0,0 +1,5 @@ + +
+">test + +
\ No newline at end of file diff --git a/3.0/modules/social_share/views/google.html.php b/3.0/modules/social_share/views/google.html.php new file mode 100644 index 00000000..1f45994e --- /dev/null +++ b/3.0/modules/social_share/views/google.html.php @@ -0,0 +1,14 @@ + +
+ +
" annotation="">
+ + + +
\ No newline at end of file diff --git a/3.0/modules/social_share/views/twitter.html.php b/3.0/modules/social_share/views/twitter.html.php new file mode 100644 index 00000000..85048874 --- /dev/null +++ b/3.0/modules/social_share/views/twitter.html.php @@ -0,0 +1,5 @@ + +
+" data-count="">Tweet + +
\ No newline at end of file