From 4f79c4050ced05a7bfc6dec277e48be008dd1c8f Mon Sep 17 00:00:00 2001 From: guetz Date: Tue, 20 Jul 2021 16:32:55 +0200 Subject: [PATCH] Boostrap themes fix * Move the share button in the menubar (add button_private_share_picture.tpl) * Allow theme to extend tpl files --- css/style.css | 8 +- main.inc.php | 20 ++- patch | 163 ++++++++++++++++++ template/button_private_share_picture.tpl | 4 + ...{picture.tpl => private_share_picture.tpl} | 2 - 5 files changed, 186 insertions(+), 11 deletions(-) create mode 100644 patch create mode 100644 template/button_private_share_picture.tpl rename template/{picture.tpl => private_share_picture.tpl} (95%) diff --git a/css/style.css b/css/style.css index 9e7bd5a..cca6d9f 100644 --- a/css/style.css +++ b/css/style.css @@ -1,9 +1,5 @@ -.pshare { - padding: 10px 0 10px 7px; -} - -.pshare a { - text-decoration:none !important; +.pwg-button.pshare-open { + font-size: 17px; } #pshare_form { diff --git a/main.inc.php b/main.inc.php index 831eadf..b9d097c 100644 --- a/main.inc.php +++ b/main.inc.php @@ -26,6 +26,10 @@ function pshare_init() global $conf; load_language('plugin.lang', PSHARE_PATH); + + global $template; + + $template->set_template_dir(PSHARE_PATH.'template/'); } add_event_handler('get_admin_plugin_menu_links', 'pshare_admin_menu'); @@ -199,7 +203,7 @@ function pshare_section_init() exit(); } - $template->set_filename('shared_picture', realpath(PSHARE_PATH.'template/shared_picture.tpl')); + $template->set_filename('shared_picture', 'shared_picture.tpl'); $derivative = new DerivativeImage(ImageStdParams::get_by_type(IMG_MEDIUM), $src_image); @@ -248,6 +252,16 @@ function pshare_section_init() } } +add_event_handler('loc_begin_picture', 'pshare_begin_picture'); +function pshare_begin_picture() +{ + global $template; + + $template->set_filename('pshare_button_share', 'button_private_share_picture.tpl'); + $template->add_picture_button($template->parse('pshare_button_share', true), 50); +} + + add_event_handler('loc_end_picture', 'pshare_end_picture'); function pshare_end_picture() { @@ -267,8 +281,8 @@ function pshare_end_picture() if (!isset($conf['use_pshare_picture_template']) or $conf['use_pshare_picture_template']) { - $template->set_filename('pshare_picture', realpath(PSHARE_PATH.'template/picture.tpl')); - $template->assign_var_from_handle('PSHARE_CONTENT', 'pshare_picture'); + $template->set_filename('pshare_picture', 'private_share_picture.tpl'); + $template->parse('pshare_picture'); } } diff --git a/patch b/patch new file mode 100644 index 0000000..fbcabcb --- /dev/null +++ b/patch @@ -0,0 +1,163 @@ +diff --git a/css/style.css b/css/style.css +index 9e7bd5a..cca6d9f 100644 +--- a/css/style.css ++++ b/css/style.css +@@ -1,9 +1,5 @@ +-.pshare { +- padding: 10px 0 10px 7px; +-} +- +-.pshare a { +- text-decoration:none !important; ++.pwg-button.pshare-open { ++ font-size: 17px; + } + + #pshare_form { +diff --git a/main.inc.php b/main.inc.php +index 831eadf..b9d097c 100644 +--- a/main.inc.php ++++ b/main.inc.php +@@ -26,6 +26,10 @@ function pshare_init() + global $conf; + + load_language('plugin.lang', PSHARE_PATH); ++ ++ global $template; ++ ++ $template->set_template_dir(PSHARE_PATH.'template/'); + } + + add_event_handler('get_admin_plugin_menu_links', 'pshare_admin_menu'); +@@ -199,7 +203,7 @@ SELECT + exit(); + } + +- $template->set_filename('shared_picture', realpath(PSHARE_PATH.'template/shared_picture.tpl')); ++ $template->set_filename('shared_picture', 'shared_picture.tpl'); + + $derivative = new DerivativeImage(ImageStdParams::get_by_type(IMG_MEDIUM), $src_image); + +@@ -248,6 +252,16 @@ SELECT * + } + } + ++add_event_handler('loc_begin_picture', 'pshare_begin_picture'); ++function pshare_begin_picture() ++{ ++ global $template; ++ ++ $template->set_filename('pshare_button_share', 'button_private_share_picture.tpl'); ++ $template->add_picture_button($template->parse('pshare_button_share', true), 50); ++} ++ ++ + add_event_handler('loc_end_picture', 'pshare_end_picture'); + function pshare_end_picture() + { +@@ -267,8 +281,8 @@ function pshare_end_picture() + + if (!isset($conf['use_pshare_picture_template']) or $conf['use_pshare_picture_template']) + { +- $template->set_filename('pshare_picture', realpath(PSHARE_PATH.'template/picture.tpl')); +- $template->assign_var_from_handle('PSHARE_CONTENT', 'pshare_picture'); ++ $template->set_filename('pshare_picture', 'private_share_picture.tpl'); ++ $template->parse('pshare_picture'); + } + } + +diff --git a/template/picture.tpl b/template/picture.tpl +deleted file mode 100644 +index 157c4b7..0000000 +--- a/template/picture.tpl ++++ /dev/null +@@ -1,88 +0,0 @@ +-{combine_css path="plugins/private_share/css/fontello/css/pshare-fontello.css"} +- +-{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'} +-{combine_css id='colorbox' path='themes/default/js/plugins/colorbox/style2/colorbox.css'} +-{combine_css path='plugins/private_share/css/style.css'} +- +-
{'Share'|translate}
+- +-{footer_script require='jquery'} +-// popup +-jQuery('.pshare-open').colorbox({ +- inline:true, +- href:"#pshare_form" +-}); +- +-jQuery(document).on('click', '.pshare-close', function(e) { +- jQuery("#pshare_form .formInfo").css('visibility', 'hidden'); +- jQuery("[name=pshare_form]").trigger("reset"); +- jQuery('.pshare-open').colorbox.close(); +- e.preventDefault(); +-}); +- +-jQuery('#pshare_form').submit(function(e){ +- jQuery(".formActions .loading").css("visibility", "visible"); +- +- jQuery.ajax({ +- url: "ws.php?format=json&method=pshare.share.create", +- type:"POST", +- data: jQuery(this).serialize(), +- success:function(data) { +- var data = jQuery.parseJSON(data); +- if (data.stat == 'ok') { +- var html_message = '✔ '+data.result.message+''; +- html_message+= ' {'Close'|translate}'; +- +- jQuery("#pshare_form .formInfo") +- .html(html_message) +- .css('visibility', 'visible') +- ; +- } +- else { +- jQuery("#pshare_form .formInfo") +- .html('✘ '+data.message+'') +- .css('visibility', 'visible') +- ; +- } +- +- jQuery(".formActions .loading").css("visibility", "hidden"); +- }, +- error:function(XMLHttpRequest, textStatus, errorThrows) { +- alert("error calling Piwigo API"); +- } +- }); +- +- e.preventDefault(); +-}); +-{/footer_script} +- +-
+-
+-
✘ oups, problem occured {'Close'|translate}
+- +- +- +- +- +- +- +- +- +- +-
{'Email address'|@translate}
{'Expires in'|@translate} +- +-
+- +-

+- +- {'Cancel'|translate} +- +-

+- +-
+-
+\ No newline at end of file diff --git a/template/button_private_share_picture.tpl b/template/button_private_share_picture.tpl new file mode 100644 index 0000000..6336b59 --- /dev/null +++ b/template/button_private_share_picture.tpl @@ -0,0 +1,4 @@ + + + {'Share'|translate} + \ No newline at end of file diff --git a/template/picture.tpl b/template/private_share_picture.tpl similarity index 95% rename from template/picture.tpl rename to template/private_share_picture.tpl index 157c4b7..eec2a48 100644 --- a/template/picture.tpl +++ b/template/private_share_picture.tpl @@ -4,8 +4,6 @@ {combine_css id='colorbox' path='themes/default/js/plugins/colorbox/style2/colorbox.css'} {combine_css path='plugins/private_share/css/style.css'} -
{'Share'|translate}
- {footer_script require='jquery'} // popup jQuery('.pshare-open').colorbox({