リビジョン | 92 (tree) |
---|---|
日時 | 2020-10-02 04:12:54 |
作者 | derekwildstar |
Zost.bsdesign e assets/_/css/styles.css
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Estilo da lista de anexos adicionado
assets/_/php/helpers.php
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Incluídos métodos para criação condicional de opções para o TinyMCE
Incluída o atributo templateHref nas opções zost do TinyMCE
assets/tinymce/js/plugins/zostplugins/plugin.min.js
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Incluído código para exibição da tela de anexos no TinyMCE (não concluído)
html/com_content/form/edit.php
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Adicionado ao TinyMCE os botões para exibição da tela de anexos
html/com_media/images/default.php
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Alterada a forma de instanciação de zostHelpers
html/com_attachments/upload/default.php
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Arquivo que serve para customizar a tela de upload de anexos
Lista de ignorância atualizada
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
@@ -433,7 +433,7 @@ | ||
433 | 433 | text-transform: uppercase; |
434 | 434 | } |
435 | 435 | |
436 | -/* body.contentpane é a identificação do body da janela popup de seleção de mídia. Ele precisa ter características semelhantes ao div.module-contents, para que seu conteúdo fique semelhante àquilo que apareceria numa página comum */ | |
436 | +/* body.contentpane é a identificação do body da janela popup de seleção de mídia e de outras similares. Ele precisa ter características semelhantes ao div.module-contents, para que seu conteúdo fique semelhante àquilo que apareceria numa página comum */ | |
437 | 437 | |
438 | 438 | div.module-contents, body.contentpane { |
439 | 439 | margin: 5px; |
@@ -1253,6 +1253,10 @@ | ||
1253 | 1253 | background-color: var(--module-background-color); |
1254 | 1254 | } |
1255 | 1255 | |
1256 | +body.contentpane > div.attachmentsList > table > caption > span { | |
1257 | + background-color: var(--page-background-color); | |
1258 | +} | |
1259 | + | |
1256 | 1260 | div.attachmentsList img.imagelink { |
1257 | 1261 | position: relative; |
1258 | 1262 | top: -2px; |
@@ -25,6 +25,7 @@ | ||
25 | 25 | use Joomla\CMS\Router\Route; |
26 | 26 | use Joomla\CMS\Filesystem\Folder; |
27 | 27 | use Joomla\CMS\HTML\HTMLHelper; |
28 | +use Joomla\CMS\Plugin\PluginHelper; | |
28 | 29 | |
29 | 30 | use \PDO; |
30 | 31 |
@@ -1749,15 +1750,198 @@ | ||
1749 | 1750 | $attributes = 'class="custom-select custom-select-sm" onchange="setFrameUrl(this.options[this.selectedIndex].value)" disabled="disabled"'; |
1750 | 1751 | return HTMLHelper::_("select.genericlist", $options, $aId, $attributes, "value", "text", $aInitialFolder); |
1751 | 1752 | } |
1753 | + /** | |
1754 | + * Injeta no objeto zostOptions as opções para exibição do seletor de mídias. | |
1755 | + * As regras para sua exibição estão em plugins/editors-xtd/image/image.php, | |
1756 | + * na função "onDisplay". Na mesma pasta (editors-xtd) estão outros fontes | |
1757 | + * que tem regras para outras funcionalidades. As regras de cada uma delas | |
1758 | + * também encontra-se em "onDisplay". Esta função é praticamente um | |
1759 | + * "onDisplay" modificado para retornar apenas o conteúdo útil | |
1760 | + * @param object Instância do objeto que contém as opções do plugin zost, as | |
1761 | + * quais serão incrementadas com as opções que a função atual provê | |
1762 | + * opcionalmente | |
1763 | + * @param mixed Asset (?) | |
1764 | + * @param integer Id do autor que está criando ou modificando o conteúdo | |
1765 | + * @param string Id do <textarea> associado ao TinyMCE | |
1766 | + */ | |
1767 | + private function addTinyMCEMediaSelectorOptions($aZostOptions, $aAsset, $aAuthor, $aTextAreaId) { | |
1768 | + $extension = $this->app->input->get("option"); | |
1769 | + /* | |
1770 | + Não entendi para que serve o bloco de código a seguir, por isso eu | |
1771 | + apenas reproduzi o código original. Ele deve estar correto | |
1772 | + */ | |
1773 | + if ($extension === "com_categories") { | |
1774 | + $extension = explode(".", $this->app->input->get("extension","com_content"))[0]; | |
1775 | + } | |
1776 | + | |
1777 | + $aAsset = $aAsset !== "" ? $aAsset : $extension; | |
1778 | + /* | |
1779 | + Neste ponto são verificadas várias permissões a fim de saber se há | |
1780 | + permissão para abrir o seletor de mídias. Caso essa condição seja | |
1781 | + verdadeira, o atributo adicional será incluído em $zostOptions | |
1782 | + */ | |
1783 | + if ($this->usr->authorise("core.edit", $aAsset) | |
1784 | + || $this->usr->authorise("core.create", $aAsset) | |
1785 | + || (count($this->usr->getAuthorisedCategories($aAsset, "core.create")) > 0) | |
1786 | + || ($this->usr->authorise("core.edit.own", $aAsset) && $aAuthor === $this->usr->id) | |
1787 | + || (count($this->usr->getAuthorisedCategories($extension,"core.edit")) > 0) | |
1788 | + || (count($this->usr->getAuthorisedCategories($extension,"core.edit.own")) > 0 && $aAuthor === $this->usr->id)) { | |
1789 | + // https://www.zettaomnis.net.br/portal/?option=com_media&view=images&tmpl=component&e_name=jform_articletext&asset=306&author=24 | |
1790 | + $aZostOptions->mediaSelector = new \stdClass(); | |
1791 | + $aZostOptions->mediaSelector->href = $this->baseSite(true) . "/?option=com_media&view=images&tmpl=component&asset=$aAsset&author=$aAuthor&e_name=$aTextAreaId"; | |
1792 | + //$zostOptions->mediaSelector->width = 800; | |
1793 | + //$zostOptions->mediaSelector->height = 643; | |
1794 | + } | |
1795 | + } | |
1796 | + /** | |
1797 | + * Injeta no objeto zostOptions as opções para exibição da janela de upload | |
1798 | + * de anexos. As regras para sua exibição estão em | |
1799 | + * plugins/editors-xtd/add_attachment/add_attachment.php, na função | |
1800 | + * "onDisplay". Esta função é praticamente um "onDisplay" modificado para | |
1801 | + * retornar apenas o conteúdo útil | |
1802 | + * @param object Instância do objeto que contém as opções do plugin zost, as | |
1803 | + * quais serão incrementadas com as opções que a função atual provê | |
1804 | + * opcionalmente | |
1805 | + */ | |
1806 | + private function addTinyMCEAddAttachmentsOptions($aZostOptions) { | |
1807 | + // Avoid displaying the button for anything except for registered parents | |
1808 | + $parent_type = $this->app->input->getCmd("option"); | |
1809 | + | |
1810 | + if (!$parent_type) { | |
1811 | + return; | |
1812 | + } | |
1813 | + | |
1814 | + $parent_entity = "default"; | |
1815 | + $editor = "article"; | |
1816 | + // Handle categories specially (since they are really com_content) | |
1817 | + if ($parent_type == "com_categories") { | |
1818 | + $parent_type = "com_content"; | |
1819 | + $parent_entity = "category"; | |
1820 | + $editor = "category"; | |
1821 | + } | |
1822 | + // Get the parent ID (id or first of cid array). NOTE: $parent_id=0 | |
1823 | + // means no id (usually means creating a new entity) | |
1824 | + $cid = $this->app->input->get("cid", array(0), "INT"); | |
1825 | + $parent_id = 0; | |
1826 | + | |
1827 | + if (count($cid) > 0) { | |
1828 | + $parent_id = $cid[0]; | |
1829 | + } | |
1830 | + | |
1831 | + if ( $parent_id == 0) { | |
1832 | + $a_id = $this->app->input->getInt("a_id"); | |
1752 | 1833 | |
1834 | + if (!is_null($a_id)) { | |
1835 | + $parent_id = $a_id; | |
1836 | + } | |
1837 | + } | |
1838 | + | |
1839 | + if ($parent_id == 0) { | |
1840 | + $nid = $this->app->input->getInt("id"); | |
1841 | + | |
1842 | + if (!is_null($nid)) { | |
1843 | + $parent_id = (int)$nid; | |
1844 | + } | |
1845 | + } | |
1846 | + // Check for the special case where we are creating an article from a category list | |
1847 | + $item_id = $this->app->input->getInt("Itemid"); | |
1848 | + $menu = $this->app->getMenu(); | |
1849 | + $menu_item = $menu->getItem($item_id); | |
1850 | + // Abaixo eu mantive os operadores "and", pois eles funcionam de forma | |
1851 | + // diferente de &&, e não consegui entender | |
1852 | + if ($menu_item and ($menu_item->query['view'] == 'category') and empty($a_id) ) { | |
1853 | + $parent_entity = 'article'; | |
1854 | + $parent_id = NULL; | |
1855 | + } | |
1856 | + // Get the article/parent handler | |
1857 | + PluginHelper::importPlugin("attachments"); | |
1858 | + | |
1859 | + $apm = getAttachmentsPluginManager(); | |
1860 | + | |
1861 | + if (!$apm->attachmentsPluginInstalled($parent_type) ) { | |
1862 | + // Exit if there is no Attachments plugin to handle this parent_type | |
1863 | + return; | |
1864 | + } | |
1865 | + // Figure out where we are and construct the right link and set | |
1866 | + $base_url = Uri::root(true); | |
1867 | + | |
1868 | + if ($this->app->isAdmin() ) { | |
1869 | + $base_url = str_replace('/administrator','', $base_url); | |
1870 | + } | |
1871 | + // Get the parent handler | |
1872 | + $parent = $apm->getAttachmentsPlugin($parent_type); | |
1873 | + $parent_entity = $parent->getCanonicalEntityId($parent_entity); | |
1874 | + | |
1875 | + if ($parent_id == 0) { | |
1876 | + // Last chance to get the id in extension editors | |
1877 | + $view = $this->app->input->getWord("view"); | |
1878 | + $layout = $this->app->input->getWord("layout"); | |
1879 | + $parent_id = $parent->getParentIdInEditor($parent_entity, $view, $layout); | |
1880 | + } | |
1881 | + // Make sure we have permissions to add attachments to this article or | |
1882 | + // category | |
1883 | + if (!$parent->userMayAddAttachment($parent_id, $parent_entity, $parent_id == 0)) { | |
1884 | + return; | |
1885 | + } | |
1886 | + // Se o fluxo chegar neste ponto, temos permissão para usar o upload de | |
1887 | + // arquivos | |
1888 | + $aZostOptions->attachments = new \stdClass(); | |
1889 | + /* | |
1890 | + O terceiro parâmetro de "getEntityAddUrl" adiciona ao url um parâmetro | |
1891 | + "from" que, por padrão, recebe o valor "closeme". Este parêmetro é | |
1892 | + checado pela função "knownFroms" que existe em attachments_plugin.php e | |
1893 | + é incrementads em attachmens_for_contents.php. Basicamente esta função | |
1894 | + retorna um array de possíveis valores que são verificados, por exemplo, | |
1895 | + em com_attachments/controller.php nos métodos "save()" e "delete()" a | |
1896 | + fim de saber se ao pressionar o botão upload ou clicar no link de | |
1897 | + remoção a janela popup precisa ser fechada e os anexos exibidos na | |
1898 | + janela pai do popup precisam ser atualizados. Em suma, se o valor de | |
1899 | + "from" estiver dentre os valores retornados por "knownFroms" um js será | |
1900 | + executado para fechar a janela popup e atualizar uma lista de anexos | |
1901 | + existente na jenala pai do popup. Como eu não quero que esse | |
1902 | + comportamento padrão seja executado, pois ele usa scripts depreciados, | |
1903 | + no terceiro parâmetro de "getEntityAddUrl" eu estou passando o valor | |
1904 | + "zostTinyMCE". Isso é suficiente para que scripts e funções antigas não | |
1905 | + sejam executados, porém há um efeito colateral desagradável, Ao usar um | |
1906 | + valor diferente de "closeme" no parâmetro "from", o parâmetro adicional | |
1907 | + "tmpl" não será adicionado ao url, fazendo com que a página de upload de | |
1908 | + anexos seja aberta na forma padrão do joomla, isto é, carregando o | |
1909 | + template atual e o conteúdo da janela de upload de anexos na parte | |
1910 | + central do template! Isso pode ser visto dentro do método "upload()", do | |
1911 | + arquivo controller.php, há uma verificação da presença de "closeme" em | |
1912 | + "from" e se houver, o parâmetro tmpl é adicionado ao request. Esse | |
1913 | + problema é resolvido simplesmente colocando "tmpl=component" no final do | |
1914 | + link. Pelo que pude entender, ao usar o parâmetro "tmpl=component", | |
1915 | + nenhum template será carregado. Isso pode ser útil no futuro. | |
1916 | + | |
1917 | + Mesmo depois de fazer isso tudo o comportamento ainda não era adequado. | |
1918 | + Ao abrir a tela de anexos e adicionar um anexo, devido a forma como as | |
1919 | + verificações estão sendo feitas no método "save()", a página inicial do | |
1920 | + site estava sendo recarregada após a confirmação do salvamento, dentro | |
1921 | + do <iframe> da jenala popup. Diante disso, eu não achei outra | |
1922 | + alternativa a não ser, alterar os arquivo controller.php a fim de que | |
1923 | + ele tenha um comportamento diferente, caso "from" seja "zostTinyMCE". | |
1924 | + Abra o arquivo e verifique lá o que eu fiz | |
1925 | + */ | |
1926 | + $aZostOptions->attachments->href = $this->baseSite(true) . "/" . $parent->getEntityAddUrl($parent_id, $parent_entity, "zostTinyMCE") . "&editor=$editor"; | |
1927 | + //$aZostOptions->attachments->width = 800; | |
1928 | + //$aZostOptions->attachments->height = 643; | |
1929 | + } | |
1930 | + /** | |
1931 | + * Cria as opções específicas do plugin zost | |
1932 | + * @param mixed Asset (?) | |
1933 | + * @param integer Id do autor que está criando ou modificando o conteúdo | |
1934 | + * @param string Id do <textarea> associado ao TinyMCE | |
1935 | + */ | |
1753 | 1936 | public function tinyMCEZostOptions($aAsset, $aAuthor, $aTextAreaId) { |
1754 | 1937 | $zostOptions = new \stdClass(); |
1938 | + $zostOptions->templateHref = $this->templateHref(); | |
1755 | 1939 | $zostOptions->codemirror = new \stdClass(); |
1756 | 1940 | /* |
1757 | 1941 | Url absoluto a partir da raiz do site com a barra do final. Todos os |
1758 | 1942 | outros caminhos após a linha abaixo são relativos a este url absoluto |
1759 | 1943 | */ |
1760 | - $zostOptions->codemirror->baseHref = $this->templateHref() . "/assets/codemirror/"; | |
1944 | + $zostOptions->codemirror->baseHref = $zostOptions->templateHref . "/assets/codemirror/"; | |
1761 | 1945 | $zostOptions->codemirror->mainJavaScript = "js/codemirror.js"; |
1762 | 1946 | $zostOptions->codemirror->mainStyleSheet = "css/codemirror.css"; |
1763 | 1947 | $zostOptions->codemirror->config = new \stdClass(); |
@@ -1787,40 +1971,9 @@ | ||
1787 | 1971 | Verificações são feitas a fim de saber se mais atributos serão |
1788 | 1972 | adicionados. As regras incluem o código que valida se a pessoa tem ou |
1789 | 1973 | não tem permissão para realizar determinada ação. |
1790 | - | |
1791 | - A primeira verificação | |
1792 | - diz respeito ao botão que chama o seletor de mídias do Joomla. As regras | |
1793 | - para sua exibição estão em plugins/editors-xtd/image/image.php. Na mesma | |
1794 | - pasta (editors-xtd) estão outros fontes que tem regras para outras | |
1795 | - funcionalidades. | |
1796 | 1974 | */ |
1797 | - $extension = $this->app->input->get("option"); | |
1798 | - /* | |
1799 | - Não entendi para que serve o bloco de código a seguir, por isso eu | |
1800 | - apenas reproduzi o código original. Ele deve estar correto | |
1801 | - */ | |
1802 | - if ($extension === "com_categories") { | |
1803 | - $extension = explode(".", $this->app->input->get("extension","com_content"))[0]; | |
1804 | - } | |
1805 | - | |
1806 | - $aAsset = $aAsset !== "" ? $aAsset : $extension; | |
1807 | - /* | |
1808 | - Neste ponto são verificadas várias permissões a fim de saber se há | |
1809 | - permissão para abrir o seletor de mídias. Caso essa condição seja | |
1810 | - verdadeira, o atributo adicional será incluído em $zostOptions | |
1811 | - */ | |
1812 | - if ($this->usr->authorise("core.edit", $aAsset) | |
1813 | - || $this->usr->authorise("core.create", $aAsset) | |
1814 | - || (count($this->usr->getAuthorisedCategories($aAsset, "core.create")) > 0) | |
1815 | - || ($this->usr->authorise("core.edit.own", $aAsset) && $aAuthor === $this->usr->id) | |
1816 | - || (count($this->usr->getAuthorisedCategories($extension,"core.edit")) > 0) | |
1817 | - || (count($this->usr->getAuthorisedCategories($extension,"core.edit.own")) > 0 && $aAuthor === $this->usr->id)) { | |
1818 | - // https://www.zettaomnis.net.br/portal/?option=com_media&view=images&tmpl=component&e_name=jform_articletext&asset=306&author=24 | |
1819 | - $zostOptions->mediaSelector = new \stdClass(); | |
1820 | - $zostOptions->mediaSelector->href = "/portal/?option=com_media&view=images&tmpl=component&asset=$aAsset&author=$aAuthor&e_name=$aTextAreaId"; | |
1821 | - //$zostOptions->mediaSelector->width = 800; | |
1822 | - //$zostOptions->mediaSelector->height = 550; | |
1823 | - } | |
1975 | + $this->addTinyMCEMediaSelectorOptions($zostOptions, $aAsset, $aAuthor, $aTextAreaId); | |
1976 | + $this->addTinyMCEAddAttachmentsOptions($zostOptions); | |
1824 | 1977 | |
1825 | 1978 | return json_encode($zostOptions); |
1826 | 1979 | } |
@@ -250,10 +250,40 @@ | ||
250 | 250 | ,onAction: function() { openMediaSelectorDialog(); } |
251 | 251 | }); |
252 | 252 | // ========================================================================= |
253 | + // == Gerenciar anexos ===================================================== | |
254 | + aEditor.ui.registry.addIcon("paperclip",'<svg viewBox="0 0 8 8" style="height: 1rem;"><use href="' + aEditor.settings.zost.templateHref + '/assets/_/img/open-iconic.min.svg#paperclip"></use></svg>'); | |
255 | + | |
256 | + function openAddAttachmentsDialog() { | |
257 | + if (!aEditor.settings.zost || !aEditor.settings.zost.attachments) { | |
258 | + aEditor.windowManager.alert("As configurações do plugin de adição de anexos não existem. Não é possível continuar. Talvez você não tenha permissão para acessar este recurso"); | |
259 | + } else { | |
260 | + const dialogWidth = aEditor.settings.zost.attachments.width ? aEditor.settings.zost.attachments.width : 800; | |
261 | + const dialogHeight = aEditor.settings.zost.attachments.height ? aEditor.settings.zost.attachments.height : 643; | |
253 | 262 | |
263 | + const config = {title: "Gerenciar anexos" | |
264 | + ,url: aEditor.settings.zost.attachments.href | |
265 | + ,width: dialogWidth | |
266 | + ,height: dialogHeight | |
267 | + ,buttons: [{type: "cancel" | |
268 | + ,text: "Cancelar"}] | |
269 | + } | |
254 | 270 | |
271 | + aEditor.windowManager.openUrl(config); | |
272 | + } | |
273 | + } | |
274 | + | |
275 | + aEditor.ui.registry.addButton("joomlamanageattachments" | |
276 | + ,{text: "Gerenciar anexos" | |
277 | + ,icon: "paperclip" | |
278 | + ,onAction: function () { openAddAttachmentsDialog(); } | |
279 | + }); | |
255 | 280 | |
256 | - | |
281 | + aEditor.ui.registry.addMenuItem("joomlamanageattachments" | |
282 | + ,{text: "Gerenciar anexos" | |
283 | + ,icon: "paperclip" | |
284 | + ,onAction: function() { openAddAttachmentsDialog(); } | |
285 | + }); | |
286 | + // ========================================================================= | |
257 | 287 | return {getMetadata: function () { return {name: "Plugin ZOST" |
258 | 288 | ,url: "http://www.zettaomnis.net.br"}; |
259 | 289 | }}; |
@@ -0,0 +1,317 @@ | ||
1 | +<?php | |
2 | +/******************************************************************************* | |
3 | +Nome: | |
4 | + com_attachments/upload/default.php | |
5 | + | |
6 | +Descrição: | |
7 | + Script responsável por renderizar o componente que exibe a tela de adição de | |
8 | + anexos | |
9 | + | |
10 | +Site: | |
11 | + http://joomlacode.org/gf/project/attachments/frs/ | |
12 | + | |
13 | +Variáveis definidas por padrão: | |
14 | +> $this (AttachmentsViewUpload) | |
15 | +> $template | |
16 | +> $layout | |
17 | +> $layoutTemplate | |
18 | +> $lang | |
19 | +> $filetofind | |
20 | +> Variáveis definidas nos requires imediatos | |
21 | + | |
22 | +Use get_included_files() e get_defined_vars() para obter informações importantes | |
23 | +*******************************************************************************/ | |
24 | +defined("_JEXEC") or die("Restricted access"); | |
25 | +require_once(JPATH_THEMES . "/". $template . "/assets/_/php/helpers.php"); | |
26 | + | |
27 | +use Zost\Helpers; | |
28 | +use Joomla\CMS\Language\Text; | |
29 | +//use Joomla\CMS\Factory; | |
30 | +//echo(__FILE__ . ":" . __LINE__); | |
31 | + | |
32 | +$zostHelpers = Helpers::getHelpers(); | |
33 | + | |
34 | +$appInput = $zostHelpers->app->input; | |
35 | +$attachment = $this->attachment; | |
36 | +$params = $this->params; | |
37 | +$parent_id = $attachment->parent_id === null ? 0 : $attachment->parent_id; | |
38 | +// Set up to toggle between uploading file/urls | |
39 | +if ($attachment->uri_type == "file" ) { | |
40 | + $upload_toggle_button_text = "Em vez disso, informe o URL de uma arquivo"; | |
41 | + $upload_toggle_url = $this->upload_url_url; | |
42 | + $upload_button_text = "Enviar"; | |
43 | +} else { | |
44 | + $upload_toggle_button_text = "Em vez disso, selecione um arquivo a enviar"; | |
45 | + $upload_toggle_url = $this->upload_file_url; | |
46 | + $upload_button_text = "Adicionar URL"; | |
47 | +} | |
48 | +// If this is for an existing content item, modify the URL appropriately | |
49 | +if ($this->new_parent) { | |
50 | + $upload_toggle_url .= "&parent_id=0,new"; | |
51 | +} | |
52 | + | |
53 | +if ($editor = $appInput->getWord("editor")) { | |
54 | + $upload_toggle_url .= "&editor=$editor"; | |
55 | +} | |
56 | +// Prepare for error displays | |
57 | +$upload_id = "upload"; | |
58 | + | |
59 | +switch ($this->error) { | |
60 | + case "no_file": | |
61 | + $upload_id = "upload_warning"; | |
62 | + break; | |
63 | + case "file_too_big": | |
64 | + $upload_id = "upload_warning"; | |
65 | + break; | |
66 | + case "file_already_on_server": | |
67 | + $upload_id = "upload_warning"; | |
68 | + break; | |
69 | +} | |
70 | +/* | |
71 | +Quando há um erro no envio do arquivo ou do url, este scrip é chamado de forma | |
72 | +crua, exatamente como ele é, ou seja, apenas o miolo de algo que normalmente aparece dentro de <body>, por conta disso | |
73 | +precisamos recriar o html apenas neste caso. As duas funções abaixo criam o html necessário | |
74 | +*/ | |
75 | +//continue aquicriando as funcoes tais como existem em view.html.php. Talvez não seja necessário recriar o html | |
76 | +//talvez tenha como configurar aqui o document e deixar que o joomla se vire. Verifique se ->doc tem algo dentro de erro | |
77 | + | |
78 | +// If this is an error re-display, display the CSS links directly | |
79 | +if ($this->error) { | |
80 | + //echo($this->startHTML()); | |
81 | +} | |
82 | +// Realizando uma tradução básica | |
83 | +$parentEntityName = $attachment->parent_entity_name == "Article" ? "o artigo" : $attachment->parent_entity_name; | |
84 | +?> | |
85 | +<h2><?php echo(Text::sprintf("Anexos para %s \"%s\"",$parentEntityName, $attachment->parent_title)); ?></h2> | |
86 | +<?php | |
87 | +if ($this->error_msg) { | |
88 | +?> | |
89 | + <div class="formWarning" id="formWarning"><?php echo($this->error_msg); ?></div> | |
90 | +<?php | |
91 | +} | |
92 | +?> | |
93 | + <form class="attachments" enctype="multipart/form-data" name="upload_form" action="<?php echo($this->save_url); ?>" method="post"> | |
94 | + <fieldset class="form-group"> | |
95 | + <legend>Definição do anexo</legend> | |
96 | +<?php if ( $attachment->uri_type == 'file' ): ?> | |
97 | + <p><label for="<?php echo $upload_id ?>"><?php | |
98 | + echo JText::_('ATTACH_ATTACH_FILE_COLON') ?></label> | |
99 | + <a class="changeButton" href="<?php echo $upload_toggle_url ?>"><?php | |
100 | + echo $upload_toggle_button_text;?></a></p> | |
101 | + <p><input type="file" name="upload" id="<?php echo $upload_id; ?>" | |
102 | + size="78" maxlength="1024" /></p> | |
103 | + <p class="display_name"><label for="display_name" | |
104 | + title="<?php echo JText::_('ATTACH_DISPLAY_FILENAME_TOOLTIP'); ?>" | |
105 | + ><?php echo JText::_('ATTACH_DISPLAY_FILENAME_OPTIONAL_COLON'); ?></label> | |
106 | + <input type="text" name="display_name" id="display_name" | |
107 | + size="70" maxlength="80" | |
108 | + title="<?php echo JText::_('ATTACH_DISPLAY_FILENAME_TOOLTIP'); ?>" | |
109 | + value="<?php echo $attachment->display_name; ?>" /></p> | |
110 | +<?php else: ?> | |
111 | + <p><label for="<?php echo $upload_id ?>"><?php | |
112 | + echo JText::_('ATTACH_ENTER_URL') ?></label> | |
113 | + | |
114 | + <label for="verify_url"><?php echo JText::_('ATTACH_VERIFY_URL_EXISTENCE') ?></label> | |
115 | + <input type="checkbox" name="verify_url" value="verify" <?php echo $this->verify_url_checked ?> | |
116 | + title="<?php echo JText::_('ATTACH_VERIFY_URL_EXISTENCE_TOOLTIP'); ?>" /> | |
117 | + | |
118 | + <label for="relative_url"><?php echo JText::_('ATTACH_RELATIVE_URL') ?></label> | |
119 | + <input type="checkbox" name="relative_url" value="relative" <?php echo $this->relative_url_checked ?> | |
120 | + title="<?php echo JText::_('ATTACH_RELATIVE_URL_TOOLTIP'); ?>" /> | |
121 | + <a class="changeButton" href="<?php echo $upload_toggle_url ?>"><?php | |
122 | + echo $upload_toggle_button_text;?></a><br /> | |
123 | + <input type="text" name="url" id="<?php echo $upload_id; ?>" | |
124 | + size="80" maxlength="255" title="<?php echo JText::_('ATTACH_ENTER_URL_TOOLTIP'); ?>" | |
125 | + value="<?php echo $attachment->url; ?>" /><br /><?php | |
126 | + echo JText::_('ATTACH_NOTE_ENTER_URL_WITH_HTTP'); ?></p> | |
127 | + <p class="display_name"><label for="display_name" | |
128 | + title="<?php echo JText::_('ATTACH_DISPLAY_URL_TOOLTIP'); ?>" | |
129 | + ><?php echo JText::_('ATTACH_DISPLAY_URL_COLON'); ?></label> | |
130 | + <input type="text" name="display_name" id="display_name" | |
131 | + size="70" maxlength="80" | |
132 | + title="<?php echo JText::_('ATTACH_DISPLAY_URL_TOOLTIP'); ?>" | |
133 | + value="<?php echo $attachment->display_name; ?>" /></p> | |
134 | +<?php endif; ?> | |
135 | + <p><label for="description"><?php echo JText::_('ATTACH_DESCRIPTION_COLON'); ?></label> | |
136 | + <input type="text" name="description" id="description" | |
137 | + size="70" maxlength="255" | |
138 | + value="<?php echo stripslashes($attachment->description); ?>" /></p> | |
139 | +<?php if ( $this->may_publish ): ?> | |
140 | + <div class="at_control"><label><?php echo JText::_('ATTACH_PUBLISHED'); ?></label><?php echo $this->publish; ?></div> | |
141 | +<?php endif; ?> | |
142 | +<?php if ( $params->get('allow_frontend_access_editing', false) ): ?> | |
143 | + | |
144 | + <div class="at_control"><label for="access" title="<?php echo $this->access_level_tooltip; ?>"><? echo JText::_('ATTACH_ACCESS_COLON'); ?></label> <?php echo $this->access_level; ?></div> | |
145 | +<?php endif; ?> | |
146 | + <?php if ( $params->get('user_field_1_name', false) ): ?> | |
147 | + <p><label for="user_field_1"><?php echo $params->get('user_field_1_name'); ?>:</label> | |
148 | + <input type="text" name="user_field_1" id="user_field_1" size="70" maxlength="100" | |
149 | + value="<?php echo stripslashes($attachment->user_field_1); ?>" /></p> | |
150 | + <?php endif; ?> | |
151 | + <?php if ( $params->get('user_field_2_name', false) ): ?> | |
152 | + <p><label for="user_field_2"><?php echo $params->get('user_field_2_name'); ?>:</label> | |
153 | + <input type="text" name="user_field_2" id="user_field_2" size="70" maxlength="100" | |
154 | + value="<?php echo stripslashes($attachment->user_field_2); ?>" /></p> | |
155 | + <?php endif; ?> | |
156 | + <?php if ( $params->get('user_field_3_name', false) ): ?> | |
157 | + <p><label for="user_field_3"><?php echo $params->get('user_field_3_name'); ?>:</label> | |
158 | + <input type="text" name="user_field_3" id="user_field_3" size="70" maxlength="100" | |
159 | + value="<?php echo stripslashes($attachment->user_field_3); ?>" /></p> | |
160 | + <?php endif; ?> | |
161 | + | |
162 | + </fieldset> | |
163 | + <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> | |
164 | + <input type="hidden" name="submitted" value="TRUE" /> | |
165 | + <input type="hidden" name="save_type" value="upload" /> | |
166 | + <input type="hidden" name="uri_type" value="<?php echo $attachment->uri_type; ?>" /> | |
167 | + <input type="hidden" name="update_file" value="TRUE" /> | |
168 | + <input type="hidden" name="parent_id" value="<?php echo $parent_id; ?>" /> | |
169 | + <input type="hidden" name="parent_type" value="<?php echo $attachment->parent_type; ?>" /> | |
170 | + <input type="hidden" name="parent_entity" value="<?php echo $attachment->parent_entity; ?>" /> | |
171 | + <input type="hidden" name="new_parent" value="<?php echo $this->new_parent; ?>" /> | |
172 | + <input type="hidden" name="from" value="<?php echo $this->from; ?>" /> | |
173 | + <input type="hidden" name="Itemid" value="<?php echo $this->Itemid; ?>" /> | |
174 | + <?php echo JHtml::_( 'form.token' ); ?> | |
175 | + | |
176 | + <br/><div class="form_buttons"> | |
177 | + <input type="submit" name="submit" value="<?php echo $upload_button_text ?>" /> | |
178 | + <span class="right"> | |
179 | + <input type="button" name="cancel" value="<?php echo JText::_('ATTACH_CANCEL'); ?>" | |
180 | + onClick="window.parent.SqueezeBox.close();" /> | |
181 | + </span> | |
182 | + </div> | |
183 | + </form> | |
184 | +<?php | |
185 | + | |
186 | +// Display the auto-publish warning, if appropriate | |
187 | +if ( !$params->get('publish_default', false) && !$this->may_publish ) { | |
188 | + $msg = $params->get('auto_publish_warning', ''); | |
189 | + if ( JString::strlen($msg) == 0 ) { | |
190 | + $msg = JText::_('ATTACH_WARNING_ADMIN_MUST_PUBLISH'); | |
191 | + } | |
192 | + else { | |
193 | + $msg = JText::_($msg); | |
194 | + } | |
195 | + echo "<h2>$msg</h2>"; | |
196 | +} | |
197 | + | |
198 | +// Show the existing attachments (if any) | |
199 | +if ( $parent_id || ($parent_id === 0) ) { | |
200 | + require_once(JPATH_SITE.'/components/com_attachments/controllers/attachments.php'); | |
201 | + $controller = new AttachmentsControllerAttachments(); | |
202 | + $controller->displayString($parent_id, $attachment->parent_type, $attachment->parent_entity, | |
203 | + 'ATTACH_EXISTING_ATTACHMENTS', | |
204 | + false, false, true, $this->from); | |
205 | + } | |
206 | + | |
207 | +if ($this->error) { | |
208 | + //echo($this->endHTML()); | |
209 | +} | |
210 | +/* | |
211 | +Limpa todos os estilos existentes no array de estilos do documento. Isso faz com | |
212 | +que possamos adicionar apenas nossos próprios estilos usando métodos do próprio | |
213 | +Joomla! O mesmo pode ser feito para _scripts, _script e _style. Isso está sendo | |
214 | +feito aqui, no final do script, para que possamos remover tudo que foi | |
215 | +automaticamente colocado pelo Joomla e pelo plugin de anexos, mantendo apenas | |
216 | +nosso próprio código! | |
217 | +*/ | |
218 | +$zostHelpers->doc->_styleSheets = array(); | |
219 | +$zostHelpers->doc->_style = array(); | |
220 | +$zostHelpers->doc->_scripts = array(); | |
221 | +$zostHelpers->doc->_script = array(); | |
222 | +/* | |
223 | +Adicionando estilos e scripts personalizados usando as funções do próprio Joomla | |
224 | +*/ | |
225 | +$zostHelpers->doc->addStyleSheet("https://fonts.googleapis.com/css?family=Abel"); | |
226 | +$zostHelpers->doc->addStyleSheet("https://fonts.googleapis.com/css?family=PT+Serif:400,400i,700,700i&subset=latin-ext"); | |
227 | +$zostHelpers->doc->addStyleSheet(Helpers::cacheBuster(JPATH_THEMES . "/". $template . "/assets/bootstrap/css/bootstrap.min.css")); | |
228 | +$zostHelpers->doc->addStyleSheet(Helpers::cacheBuster(JPATH_THEMES . "/". $template . "/assets/_/css/styles.css")); | |
229 | + | |
230 | +$zostHelpers->doc->addScript(Helpers::cacheBuster(JPATH_THEMES . "/". $template . "/assets/modernizr/js/modernizr.js")); | |
231 | +$zostHelpers->doc->addScript(Helpers::cacheBuster(JPATH_THEMES . "/". $template . "/assets/jquery/js/jquery-3.5.1.min.js")); | |
232 | +$zostHelpers->doc->addScript(Helpers::cacheBuster(JPATH_THEMES . "/". $template . "/assets/bootstrap/js/bootstrap.bundle.min.js")); | |
233 | +$zostHelpers->doc->addScript(Helpers::cacheBuster(JPATH_THEMES . "/". $template . "/assets/_/js/helpers.js")); | |
234 | + | |
235 | +// Ao carregar este script, recarrega SEMPRE a lista de anexos da página pai, | |
236 | +// isso tem overhead, mas é minimo. verificar attachments_refresh.js e usar aqui | |
237 | +// verifique se existe algo mais simples. veja como é feito ao se atualizar | |
238 | +// anexos diretamente no artigo! | |
239 | +/** | |
240 | + * Define Javascript function for refreshing attachments lists | |
241 | + * | |
242 | + * Copyright (C) 2010-2016 Jonathan M. Cameron, All Rights Reserved | |
243 | + * License: http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL | |
244 | + * | |
245 | + * By Jonathan Cameron | |
246 | + * | |
247 | + * @param siteURL string the site base URL for the request | |
248 | + * @param ptype string parent_type for the attachments list parent | |
249 | + * @param pentity string parent_entity for the attachments list parent | |
250 | + * @param pid integer parent_id for the attachments list parent | |
251 | + * @param lang the current language ('' if not specified) | |
252 | + * @param from string the 'from' clause to pass in the request | |
253 | + */ | |
254 | + | |
255 | +/* | |
256 | +function refreshAttachments(siteUrl, ptype, pentity, pid, lang, from) { | |
257 | + var id = "attachmentsList_" + ptype + "_" + pentity + "_" + pid, | |
258 | + alist = document.getElementById(id), | |
259 | + url = siteUrl + "/index.php?option=com_attachments&task=attachmentsList"; | |
260 | + url += "&parent_id=" + pid; | |
261 | + url += "&parent_type=" + ptype + "&parent_entity=" + pentity; | |
262 | + url += "&lang=" + lang; | |
263 | + url += "&from=" + from + "&tmpl=component&format=raw"; | |
264 | + if (!alist) { | |
265 | + alist = window.parent.document.getElementById(id); | |
266 | + } | |
267 | + if (!alist) { | |
268 | + id = "attachmentsList_" + ptype + "_default_" + pid; | |
269 | + alist = window.parent.document.getElementById(id); | |
270 | + } | |
271 | + new window.Request({ | |
272 | + url: url, | |
273 | + method: 'get', | |
274 | + onComplete: function (response) { | |
275 | + | |
276 | + // Refresh the attachments list | |
277 | + alist.innerHTML = response; | |
278 | + | |
279 | + // Remove any old click events (since they are for a deleted/updated SqueezeBox) | |
280 | + $$('a.modal-button').removeEvents('click'); | |
281 | + | |
282 | + // Since the html has been replaced, we need to reconnect the modal button events | |
283 | + window.SqueezeBox.initialize({}); | |
284 | + window.SqueezeBox.assign($$('a.modal-button'), { parse: 'rel' }); | |
285 | + } | |
286 | + }).send(); | |
287 | +}; | |
288 | + | |
289 | +*/ | |
290 | + | |
291 | +$scriptDeclaration = <<< EOS | |
292 | + /* <![CDATA[ */ | |
293 | + /* | |
294 | + Verifica se na jenala pai existe uma lista de anexos a ser atualizada e | |
295 | + apenas continua caso haja | |
296 | + */ | |
297 | + /* ]]> */ | |
298 | +EOS; | |
299 | + | |
300 | +$zostHelpers->doc->addScriptDeclaration($scriptDeclaration); | |
301 | + | |
302 | +if ($this->error) { | |
303 | +// $this->document = &$zostHelpers->doc; | |
304 | +} | |
305 | + | |
306 | +/* | |
307 | + | |
308 | +this = AttachmentsViewUpload | |
309 | + | |
310 | + $document = JFactory::getDocument(); | |
311 | + $this->assignRef('document', $document); | |
312 | + | |
313 | + $app = JFactory::getApplication(); | |
314 | + $this->template = $app->getTemplate(true)->template; | |
315 | + $template_dir = $this->baseurl.'/templates/'.$this->template; | |
316 | + | |
317 | +*/ |
@@ -285,10 +285,10 @@ | ||
285 | 285 | ,insert: { title: "Insert", items: "media image link | anchor charmap hr nonbreaking template insertdatetime pagebreak"} |
286 | 286 | ,view: { title: "View", items: "visualblocks visualchars visualaid | fullscreen preview"} |
287 | 287 | ,format: { title: "Format", items: "bold italic underline strikethrough subscript superscript | formats | removeformat"} |
288 | - ,zost: { title: "ZØST", items: "joomlapagebreak joomlareadmore joomlamediaselecor | adsenseplaceholder codemirror"}} | |
288 | + ,zost: { title: "ZØST", items: "joomlapagebreak joomlareadmore joomlamediaselecor joomlamanageattachments | adsenseplaceholder codemirror"}} | |
289 | 289 | ,toolbar1: "fullscreen searchreplace | undo redo | selectall cut copy paste pastetext | bold italic underline strikethrough subscript superscript removeformat formatselect" |
290 | 290 | ,toolbar2: "alignleft aligncenter alignright alignjustify alignnone | bullist numlist indent outdent | image link unlink anchor charmap emoticons hr table blockquote | code codesample" |
291 | - ,toolbar3: "joomlapagebreak joomlareadmore joomlamediaselecor" | |
291 | + ,toolbar3: "joomlapagebreak joomlareadmore joomlamediaselecor joomlamanageattachments" | |
292 | 292 | ,toolbar4: "adsenseplaceholder codemirror" |
293 | 293 | ,templates: [{title: "Template 1", description: "Exemplo", content: "Leia o conteúdo do url abaixo para saber como definir templates<br />https://www.tiny.cloud/docs/plugins/template/"}] |
294 | 294 | ,paste_data_images: true |
@@ -31,7 +31,7 @@ | ||
31 | 31 | use Joomla\CMS\Utility\Utility; |
32 | 32 | use Joomla\CMS\HTML\HTMLHelper; |
33 | 33 | |
34 | -$zostHelpers = new Helpers(); | |
34 | +$zostHelpers = Helpers::getHelpers(); | |
35 | 35 | |
36 | 36 | $appInput = $zostHelpers->app->input; |
37 | 37 |