Skip to content

Commit

Permalink
Version 1.0.0 - First Release
Browse files Browse the repository at this point in the history
  • Loading branch information
uzielweb committed Apr 16, 2017
1 parent 7d5ae30 commit 4101348
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 0 deletions.
84 changes: 84 additions & 0 deletions add_xml_fields.php
@@ -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;





}
}
?>
34 changes: 34 additions & 0 deletions add_xml_fields.xml
@@ -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>
1 change: 1 addition & 0 deletions index.html
@@ -0,0 +1 @@
<html><head></head><body></body></html>
11 changes: 11 additions & 0 deletions language/en-GB.plg_system_add_xml_fields.ini
@@ -0,0 +1,11 @@
[add_xml_fields]
PLG_SYSTEM_ADD_XML_FIELDS="ADD XML Fields"
PLG_SYSTEM_ADD_XML_FIELDS_XML_DESCRIPTION="A plugin to add XML fields to any module"
MODULES="Modules"
MODULES_DESC="Enter the modules names separated by commas. Eg.: mod_articles_latest,mod_articles_popular"
FILES="Files"
MODULES_DESC="Enter the xml files names separated by commas without extension.Each file is for each respective module. Eg.: subformed,subform"
PATH="Path of XML files"
PATH_DESC="Choose the Path of XML files.<br> If you choose 'plugins' the xml file needs to be in plugins/system/add_xml_fields/.<br> If you choose 'template override' the xml file needs to be in templates/YOURTEMPLATE/html/YOURMODULE/"
PLUGINS="Plugins"
TEMPLATE_OVERRIDE="Template override"
Expand Down
3 changes: 3 additions & 0 deletions language/en-GB.plg_system_add_xml_fields.sys.ini
@@ -0,0 +1,3 @@
[add_xml_fields]
PLG_SYSTEM_ADD_XML_FIELDS="ADD XML Fields"
PLG_SYSTEM_ADD_XML_FIELDS_XML_DESCRIPTION="A plugin to add XML fields to any module"
Expand Down
1 change: 1 addition & 0 deletions language/index.html
@@ -0,0 +1 @@
<html><head></head><body></body></html>
22 changes: 22 additions & 0 deletions language/pt-BR.plg_system_add_xml_fields.ini
@@ -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"

3 changes: 3 additions & 0 deletions language/pt-BR.plg_system_add_xml_fields.sys.ini
@@ -0,0 +1,3 @@
[add_xml_fields]
PLG_SYSTEM_ADD_XML_FIELDS="ADD XML Fields"
PLG_SYSTEM_ADD_XML_FIELDS_XML_DESCRIPTION="A plugin to add XML fields to any module"
Expand Down

0 comments on commit 4101348

Please sign in to comment.