From 52f12c3c1c25608195ed600ac2d85cf3e878a776 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 7 Mar 2024 10:46:01 +0200 Subject: [PATCH] Update plugin Added translations and page block hiding when there is one file in the element --- FilePaginatorPlugin.php | 15 +++++- languages/ru.mo | Bin 0 -> 1207 bytes languages/ru.po | 54 +++++++++++++++++++++ languages/template.pot | 49 +++++++++++++++++++ languages/uk.mo | Bin 0 -> 1213 bytes languages/uk.po | 54 +++++++++++++++++++++ views/shared/javascripts/filePagination.js | 39 +++++++++------ 7 files changed, 193 insertions(+), 18 deletions(-) create mode 100644 languages/ru.mo create mode 100644 languages/ru.po create mode 100644 languages/template.pot create mode 100644 languages/uk.mo create mode 100644 languages/uk.po diff --git a/FilePaginatorPlugin.php b/FilePaginatorPlugin.php index 94bfc40..adeb546 100644 --- a/FilePaginatorPlugin.php +++ b/FilePaginatorPlugin.php @@ -13,6 +13,7 @@ class FilePaginatorPlugin extends Omeka_Plugin_AbstractPlugin { protected $_hooks = array( + 'initialize', 'public_head', 'config', 'config_form', @@ -24,6 +25,16 @@ class FilePaginatorPlugin extends Omeka_Plugin_AbstractPlugin 'file_markup_options' ); + /** + * Add the translations. + */ + public function hookInitialize() + { + + add_translation_source(dirname(__FILE__).'/languages'); + + } + public function hookPublicHead($args) { queue_js_file('jquery.simplePagination'); @@ -46,7 +57,7 @@ public function hookConfig($args){ public function filterFilesForItem($html) { $theme = get_option('file_paginator_theme'); - return '
'.$html; + return '
'.$html; } public function filterFileMarkupOptions ($options) { @@ -68,4 +79,4 @@ public function filterFileMarkup($html,$args) { . ''; } } -?> \ No newline at end of file +?> diff --git a/languages/ru.mo b/languages/ru.mo new file mode 100644 index 0000000000000000000000000000000000000000..40c04af90ed8e5b3132062dfaa9a464ec1ac42a1 GIT binary patch literal 1207 zcmbVINlz3(6fPCF(HJ2fJvDM|`rh)rt$wsLJ!g&qzYiWpU_7>hfsR24OW3aNxtPATRx85FT|L6)O| zKvsM@-5;pjM*iNg@JXTi_;APr*-7Opj}xH^*GoOl>0IBXz6;I`5hp<;eag4Fx#HE5 z(-jM@5OKP>Lb>O99gf@XxTnZH<9lb0x}FPS9NiXW8 zFx02N;}?Y#vE}$wjKn~o$ZPX3+PNm~1a_Bfa;}%l$_TFrrzCjIC-_NrbhuugD~2O6 z51pPUt|dOn;nYnE?VYr477odSdACr=Q)??((>+kg=jlAT1Ume41@BktY@x%NX@z?> z@6p)Uddazb$6=J@QQ{r$+}O&ecqGU4TQgxMbwjV{RsBgXz@8`bKrbQm8KFf&W&!5> zF*4K0uIi7bPI^tRl6kD>^^%#^i{?J*Wm7kg^aANGC|xu6&4gam4Krz;*nSQD6;u?i z=!ShT4E!m=%*AxrT*{tm`|pibv*pGy>x(@EgY~kWPp_Lpa7C|}`ucV0HoAdfFR{ro zu4&+i$&~Pw={IHuL2PQCG5s1V+9vps)Wv_*;ovr=U;WwMHn;R8{K_2ee~SNE&}cVn Q#?w$e4QIhO2rZ+>Pdv`Ung9R* literal 0 HcmV?d00001 diff --git a/languages/ru.po b/languages/ru.po new file mode 100644 index 0000000..ea8d728 --- /dev/null +++ b/languages/ru.po @@ -0,0 +1,54 @@ +msgid "" +msgstr "" +"Content-Transfer-Encoding: 8bit\n" +"Content-Type: text/plain; charset=UTF-8\n" +"MIME-Version: 1.0\n" +"POT-Creation-Date: 2024-03-07 09:29+0200\n" +"Project-Id-Version: FilePaginator\n" +"X-Domain: FilePaginator\n" +"X-Generator: Poedit 2.2\n" +"PO-Revision-Date: \n" +"Language-Team: \n" +"Last-Translator: \n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" +"Language: ru\n" + +#: plugins/FilePaginator/FilePaginatorPlugin.php:49 +msgid "Prev" +msgstr "Предыдущий" + +#: plugins/FilePaginator/FilePaginatorPlugin.php:49 +msgid "Next" +msgstr "Следующий" + +#: plugins/FilePaginator/config_form.php:6 +msgid "Theme" +msgstr "Тема" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Light" +msgstr "Светлая" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Dark" +msgstr "Тёмная" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Compact" +msgstr "Компактный" + +#: plugins/FilePaginator/config_form.php:12 +msgid "Links" +msgstr "Ссылка" + +#: plugins/FilePaginator/config_form.php:16 +msgid "Check the box below to launch files into new tabs on click." +msgstr "Установите флажок ниже, чтобы по щелчку мыши запускать файлы на новых вкладках." + +#: plugins/FilePaginator/config_form.php:20 +msgid "Metadata" +msgstr "Метаданые" + +#: plugins/FilePaginator/config_form.php:24 +msgid "Check the box below to show file metadata." +msgstr "Установите флажок ниже, чтобы отобразить метаданные файла." diff --git a/languages/template.pot b/languages/template.pot new file mode 100644 index 0000000..a50069c --- /dev/null +++ b/languages/template.pot @@ -0,0 +1,49 @@ +msgid "" +msgstr "" +"Content-Transfer-Encoding: 8bit\n" +"Content-Type: text/plain; charset=UTF-8\n" +"MIME-Version: 1.0\n" +"POT-Creation-Date: 2024-03-07 09:29+0200\n" +"Project-Id-Version: FilePaginator\n" +"X-Domain: FilePaginator\n" +"X-Generator: LanguagesManager\n" + +#: plugins/FilePaginator/FilePaginatorPlugin.php:49 +msgid "Prev" +msgstr "" + +#: plugins/FilePaginator/FilePaginatorPlugin.php:49 +msgid "Next" +msgstr "" + +#: plugins/FilePaginator/config_form.php:6 +msgid "Theme" +msgstr "" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Light" +msgstr "" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Dark" +msgstr "" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Compact" +msgstr "" + +#: plugins/FilePaginator/config_form.php:12 +msgid "Links" +msgstr "" + +#: plugins/FilePaginator/config_form.php:16 +msgid "Check the box below to launch files into new tabs on click." +msgstr "" + +#: plugins/FilePaginator/config_form.php:20 +msgid "Metadata" +msgstr "" + +#: plugins/FilePaginator/config_form.php:24 +msgid "Check the box below to show file metadata." +msgstr "" diff --git a/languages/uk.mo b/languages/uk.mo new file mode 100644 index 0000000000000000000000000000000000000000..4c8e506e333ed328ec1f5e4ab61288b0e7f8ae35 GIT binary patch literal 1213 zcmbtQ%T5$Q6fG5BqYEG|U0fFuQ5$<25}}8|7#@ZMbYcc$;=If0}Zl>^~yqQ<+c7e38byvIxnOh)971&xPbm%9p)-sqJ6fu!tUp zNfn{^C|4Y%er1B^73X&(c)RP65I&+>%9OfTS2$vMt*Cxu`lPSsJ0=}h**7Gf$rE&hh?{0_I0wmT&L@b?bs*`{Be<2*5K&x1_RhD!wa6|$`2Cv ztvgQi(Q{q9O3@3wr#};lSM-M7M$M*P*HutADS8UxmfpcruN&4LQk&5tJiU!@ z)i6+tz<#t6&FP(J*_74UaFK)eEn05-Pgzh{U*apK8)14Eo0t_h%!Fv=P-(P)QLE6o zi-oILXTHAc7SkVe4MAvQ`n_2e87vU%!p>%!x>ly&{@I-Aci0GD8ZDry`8u@2FT<&s OFNFw5Fu{WvRrV7hy2xDs literal 0 HcmV?d00001 diff --git a/languages/uk.po b/languages/uk.po new file mode 100644 index 0000000..52b6ac8 --- /dev/null +++ b/languages/uk.po @@ -0,0 +1,54 @@ +msgid "" +msgstr "" +"Content-Transfer-Encoding: 8bit\n" +"Content-Type: text/plain; charset=UTF-8\n" +"MIME-Version: 1.0\n" +"POT-Creation-Date: 2024-03-07 09:29+0200\n" +"Project-Id-Version: FilePaginator\n" +"X-Domain: FilePaginator\n" +"X-Generator: Poedit 2.2\n" +"PO-Revision-Date: \n" +"Language-Team: \n" +"Last-Translator: \n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : 2);\n" +"Language: uk_UA\n" + +#: plugins/FilePaginator/FilePaginatorPlugin.php:49 +msgid "Prev" +msgstr "Попередній" + +#: plugins/FilePaginator/FilePaginatorPlugin.php:49 +msgid "Next" +msgstr "Наступний" + +#: plugins/FilePaginator/config_form.php:6 +msgid "Theme" +msgstr "Тема" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Light" +msgstr "Світла" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Dark" +msgstr "Темна" + +#: plugins/FilePaginator/config_form.php:9 +msgid "Compact" +msgstr "Компактний" + +#: plugins/FilePaginator/config_form.php:12 +msgid "Links" +msgstr "Посилання" + +#: plugins/FilePaginator/config_form.php:16 +msgid "Check the box below to launch files into new tabs on click." +msgstr "Поставте прапорець нижче, щоб відкривати файли в нових вкладках після натискання." + +#: plugins/FilePaginator/config_form.php:20 +msgid "Metadata" +msgstr "Метадані" + +#: plugins/FilePaginator/config_form.php:24 +msgid "Check the box below to show file metadata." +msgstr "Поставте прапорець нижче, щоб відобразити метадані файлу." diff --git a/views/shared/javascripts/filePagination.js b/views/shared/javascripts/filePagination.js index b1a47ca..e9e689c 100644 --- a/views/shared/javascripts/filePagination.js +++ b/views/shared/javascripts/filePagination.js @@ -3,26 +3,15 @@ jQuery(function($) { var pagination = $('#file-pagination') if (!pagination.length) return; var items = $(".single-file"); - + var numItems = items.length; var perPage = 1; var theme = pagination.data("theme"); + var prevText = pagination.data("prevtext"); + var nextText = pagination.data("nexttext"); items.slice(perPage).hide(); - pagination.pagination({ - items: numItems, - itemsOnPage: perPage, - cssStyle: theme, - - onPageClick: function(pageNumber) { - var showFrom = perPage * (pageNumber - 1); - var showTo = showFrom + perPage; - - items.hide() - .slice(showFrom, showTo).show(); - } - }); function checkFragment() { var hash = window.location.hash || "#page-1"; hash = hash.match(/^#page-(\d+)$/); @@ -30,6 +19,24 @@ jQuery(function($) { pagination.pagination("selectPage", parseInt(hash[1])); } }; - $(window).bind("popstate", checkFragment); - checkFragment(); + + if(numItems > 1){ + pagination.pagination({ + items: numItems, + itemsOnPage: perPage, + cssStyle: theme, + prevText: prevText, + nextText: nextText, + + onPageClick: function(pageNumber) { + var showFrom = perPage * (pageNumber - 1); + var showTo = showFrom + perPage; + + items.hide() + .slice(showFrom, showTo).show(); + } + }); + $(window).bind("popstate", checkFragment); + checkFragment(); + } });