Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
// no direct access | ||
defined ('_JEXEC') or die; | ||
|
||
class plgSystemAdd_xml_fields extends JPlugin | ||
{ | ||
/** | ||
* Load the language file on instantiation. | ||
* Note this is only available in Joomla 3.1 and higher. | ||
* If you want to support 3.0 series you must override the constructor | ||
* | ||
* @var boolean | ||
* @since <your version> | ||
*/ | ||
protected $autoloadLanguage = true; | ||
|
||
/** | ||
* Prepare form and add my field. | ||
* | ||
* @param JForm $form The form to be altered. | ||
* @param mixed $data The associated data for the form. | ||
* | ||
* @return boolean | ||
* | ||
* @since <your version> | ||
*/ | ||
function onContentPrepareForm($form, $data) | ||
{ | ||
$app = JFactory::getApplication(); | ||
$option = $app->input->get('option'); | ||
|
||
|
||
if ($app->isAdmin() or $app->isSite()) | ||
{ | ||
|
||
$pieces = explode(",", $this->params->get('filenames')); | ||
$themodules = explode(",", $this->params->get('themodules')); | ||
$db = JFactory::getDBO(); | ||
$query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1"; | ||
$db->setQuery($query); | ||
$defaultemplate = $db->loadResult(); | ||
|
||
$db2 = JFactory::getDBO(); | ||
$query2 = 'SELECT module' | ||
.' FROM #__modules' | ||
.' WHERE id = ' . $db->Quote($app->input->get("id")); | ||
$db2->setQuery($query2); | ||
$module = $db2->loadResult(); | ||
|
||
foreach($themodules as $key=>$themodule){ | ||
if ($module == $themodule){ | ||
|
||
if ($this->params->get('thepath') == 'template_override') { | ||
JForm::addFormPath(JPATH_SITE . '/templates/' . $defaultemplate . '/html/' . $themodule . '/'); | ||
} | ||
if ($this->params->get('thepath') == 'plugins') { | ||
JForm::addFormPath(JPATH_PLUGINS . '/system/add_xml_fields/'); | ||
} | ||
foreach ($pieces as $k => $piece) { | ||
$form->loadFile($pieces[$key], false); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
return true; | ||
|
||
|
||
|
||
|
||
|
||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension version="3.5" method="upgrade" type="plugin" group="system"> | ||
<name>plg_system_add_xml_fields</name> | ||
<author></author> | ||
<creationDate>2017 april 13</creationDate> | ||
<copyright></copyright> | ||
<license></license> | ||
<authorEmail></authorEmail> | ||
<authorUrl></authorUrl> | ||
<version>1.0.0</version> | ||
<description>PLG_SYSTEM_ADD_XML_FIELDS_XML_DESCRIPTION</description> | ||
<files> | ||
<filename plugin="add_xml_fields">add_xml_fields.php</filename> | ||
<filename>index.html</filename> | ||
</files> | ||
<languages folder="language"> | ||
<language tag="en-GB">en-GB.plg_system_add_xml_fields.ini</language> | ||
<language tag="en-GB">en-GB.plg_system_add_xml_fields.sys.ini</language> | ||
<language tag="pt-BR">pt-BR.plg_system_add_xml_fields.ini</language> | ||
<language tag="pt-BR">pt-BR.plg_system_add_xml_fields.sys.ini</language> | ||
</languages> | ||
<config> | ||
<fields name="params"> | ||
<fieldset name="basic"> | ||
<field name="themodules" type="text" label="MODULES" description="MODULES_DESC" default="mod_articles_latest" /> | ||
<field name="filenames" type="text" label="FILES" description="FILES_DESC" default="" /> | ||
<field name="thepath" type="list" label="PATH" description="PATH_DESC" default="plugins"> | ||
<option value="plugins">PLUGINS</option> | ||
<option value="template_override">TEMPLATE_OVERRIDE</option> | ||
</field> | ||
</fieldset> | ||
</fields> | ||
</config> | ||
</extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head></head><body></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head></head><body></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[add_xml_fields] | ||
|
||
PLG_SYSTEM_ADD_XML_FIELDS="Adicionador de Campos XML" | ||
|
||
PLG_SYSTEM_ADD_XML_FIELDS_XML_DESCRIPTION="Um plugin para adicionar campos XML a qualquer módulo" | ||
|
||
MODULES="Módulos" | ||
|
||
MODULES_DESC="Introduza os nomes dos módulos separados por vírgulas, por exemplo: mod_articles_latest, mod_articles_popular" | ||
|
||
FILES="Arquivos" | ||
|
||
MODULES_DESC="Digite os nomes dos arquivos xml separados por vírgulas sem extensão. Cada arquivo é para cada módulo respectivo. Por exemplo: subform,custom" | ||
|
||
PATH="Caminho de arquivos XML" | ||
|
||
PATH_DESC="Escolha o caminho de arquivos XML. <br> Se você escolher 'plugins' o arquivo xml precisa estar em plugins/system/add_xml_fields /. <br> Se você escolher 'Substituição de modelo' o arquivo xml precisa estar em Templates/YOURTEMPLATE/html/YOURMODULE/" | ||
|
||
PLUGINS="Plugins" | ||
|
||
TEMPLATE_OVERRIDE="Substituição de modelo" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters