Added Joomla Module builder - Compiler
This commit is contained in:
@ -157,6 +157,8 @@ class Compiler extends Infusion
|
||||
// done with error
|
||||
return false;
|
||||
}
|
||||
// if there are modules zip them
|
||||
$this->zipModules();
|
||||
// if there are plugins zip them
|
||||
$this->zipPlugins();
|
||||
// do lang mismatch check
|
||||
@ -268,6 +270,62 @@ class Compiler extends Infusion
|
||||
}
|
||||
// free up some memory
|
||||
unset($this->newFiles['dynamic']);
|
||||
// do modules if found
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module) && isset($this->newFiles[$module->key]) && ComponentbuilderHelper::checkArray($this->newFiles[$module->key]))
|
||||
{
|
||||
// move field or rule if needed
|
||||
if (isset($module->fields_rules_paths) && $module->fields_rules_paths == 2)
|
||||
{
|
||||
// check the config fields
|
||||
if (isset($module->config_fields) && ComponentbuilderHelper::checkArray($module->config_fields))
|
||||
{
|
||||
foreach ($module->config_fields as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$this->moveFieldsRules($field, $module->folder_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check the fieldsets
|
||||
if (isset($module->form_files) && ComponentbuilderHelper::checkArray($module->form_files))
|
||||
{
|
||||
foreach($module->form_files as $file => $files)
|
||||
{
|
||||
foreach ($files as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$this->moveFieldsRules($field, $module->folder_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// update the module files
|
||||
foreach ($this->newFiles[$module->key] as $module_file)
|
||||
{
|
||||
if (JFile::exists($module_file['path']))
|
||||
{
|
||||
$this->setFileContent($module_file['name'], $module_file['path'], $bom, $module->key);
|
||||
}
|
||||
}
|
||||
// free up some memory
|
||||
unset($this->newFiles[$module->key]);
|
||||
unset($this->fileContentDynamic[$module->key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// do plugins if found
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
{
|
||||
@ -310,7 +368,7 @@ class Compiler extends Infusion
|
||||
}
|
||||
}
|
||||
}
|
||||
// now move the files
|
||||
// update the plugin files
|
||||
foreach ($this->newFiles[$plugin->key] as $plugin_file)
|
||||
{
|
||||
if (JFile::exists($plugin_file['path']))
|
||||
@ -572,6 +630,27 @@ class Compiler extends Infusion
|
||||
// Trigger Event: jcb_ce_onAfterUpdateRepo
|
||||
$this->triggerEvent('jcb_ce_onAfterUpdateRepo', array(&$this->componentContext, &$this->componentPath, &$repoFullPath, &$this->componentData));
|
||||
|
||||
// move the modules to local folder repos
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module) && isset($module->file_name))
|
||||
{
|
||||
$module_context = 'module.' . $module->file_name . '.' . $module->id;
|
||||
// set the repo path
|
||||
$repoFullPath = $this->repoPath . '/' . $module->folder_name . '__joomla_' . $this->joomlaVersion;
|
||||
// Trigger Event: jcb_ce_onBeforeUpdateRepo
|
||||
$this->triggerEvent('jcb_ce_onBeforeUpdateRepo', array(&$module_context, &$module->folder_path, &$repoFullPath, &$module));
|
||||
// remove old data
|
||||
$this->removeFolder($repoFullPath, $this->componentData->toignore);
|
||||
// set the new data
|
||||
JFolder::copy($module->folder_path, $repoFullPath, '', true);
|
||||
// Trigger Event: jcb_ce_onAfterUpdateRepo
|
||||
$this->triggerEvent('jcb_ce_onAfterUpdateRepo', array(&$module_context, &$module->folder_path, &$repoFullPath, &$module));
|
||||
}
|
||||
}
|
||||
}
|
||||
// move the plugins to local folder repos
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
{
|
||||
@ -639,6 +718,60 @@ class Compiler extends Infusion
|
||||
return false;
|
||||
}
|
||||
|
||||
private function zipModules()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module) && isset($module->zip_name)
|
||||
&& ComponentbuilderHelper::checkString($module->zip_name)
|
||||
&& isset($module->folder_path)
|
||||
&& ComponentbuilderHelper::checkString($module->folder_path))
|
||||
{
|
||||
// set module context
|
||||
$module_context = $module->file_name . '.' . $module->id;
|
||||
// Component Folder Name
|
||||
$this->filepath['modules-folder'][$module->id] = $module->zip_name;
|
||||
// the name of the zip file to create
|
||||
$this->filepath['modules'][$module->id] = $this->tempPath . '/' . $module->zip_name . '.zip';
|
||||
// Trigger Event: jcb_ce_onBeforeZipModule
|
||||
$this->triggerEvent('jcb_ce_onBeforeZipModule', array(&$module_context, &$module->folder_path, &$this->filepath['modules'][$module->id], &$this->tempPath, &$module->zip_name, &$module));
|
||||
//create the zip file
|
||||
if (ComponentbuilderHelper::zip($module->folder_path, $this->filepath['modules'][$module->id]))
|
||||
{
|
||||
// now move to backup if zip was made and backup is required
|
||||
if ($this->backupPath)
|
||||
{
|
||||
$__module_context = 'module.' . $module_context;
|
||||
// Trigger Event: jcb_ce_onBeforeBackupZip
|
||||
$this->triggerEvent('jcb_ce_onBeforeBackupZip', array(&$__module_context, &$this->filepath['modules'][$module->id], &$this->tempPath, &$this->backupPath, &$module));
|
||||
// copy the zip to backup path
|
||||
JFile::copy($this->filepath['modules'][$module->id], $this->backupPath . '/' . $module->zip_name . '.zip');
|
||||
}
|
||||
|
||||
// move to sales server host
|
||||
if ($module->add_sales_server == 1)
|
||||
{
|
||||
// make sure we have the correct file
|
||||
if (isset($module->sales_server))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeMoveToServer
|
||||
$this->triggerEvent('jcb_ce_onBeforeMoveToServer', array(&$__module_context, &$this->filepath['modules'][$module->id], &$this->tempPath, &$module->zip_name, &$module));
|
||||
// move to server
|
||||
ComponentbuilderHelper::moveToServer($this->filepath['modules'][$module->id], $module->zip_name . '.zip', (int) $module->sales_server, $module->sales_server_protocol);
|
||||
}
|
||||
}
|
||||
// Trigger Event: jcb_ce_onAfterZipModule
|
||||
$this->triggerEvent('jcb_ce_onAfterZipModule', array(&$module_context, &$this->filepath['modules'][$module->id], &$this->tempPath, &$module->zip_name, &$module));
|
||||
// remove the module folder since we are done
|
||||
$this->removeFolder($module->folder_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function zipPlugins()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
|
@ -129,6 +129,13 @@ class Get
|
||||
*/
|
||||
public $joomlaPlugins = array();
|
||||
|
||||
/**
|
||||
* The Modules data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $joomlaModules = array();
|
||||
|
||||
/**
|
||||
* The custom script placeholders - we use the (xxx) to avoid detection it should be (***)
|
||||
* ##################################---> PHP/JS <---####################################
|
||||
@ -1036,6 +1043,7 @@ class Get
|
||||
'j.addfoldersfullpath' => 'addfoldersfullpath',
|
||||
'c.addsite_views' => 'addsite_views',
|
||||
'l.addjoomla_plugins' => 'addjoomla_plugins',
|
||||
'k.addjoomla_modules' => 'addjoomla_modules',
|
||||
'i.dashboard_tab' => 'dashboard_tab',
|
||||
'i.php_dashboard_methods' => 'php_dashboard_methods',
|
||||
'i.id' => 'component_dashboard_id',
|
||||
@ -1062,7 +1070,8 @@ class Get
|
||||
'h' => 'component_config',
|
||||
'i' => 'component_dashboard',
|
||||
'j' => 'component_files_folders',
|
||||
'l' => 'component_plugins'
|
||||
'l' => 'component_plugins',
|
||||
'k' => 'component_modules'
|
||||
);
|
||||
// load the joins
|
||||
foreach($joiners as $as => $join)
|
||||
@ -1683,12 +1692,26 @@ class Get
|
||||
// the default is to ignore the repo folder
|
||||
$component->toignore = array('.git');
|
||||
}
|
||||
// get all modules
|
||||
$component->addjoomla_modules = (isset($component->addjoomla_modules) && ComponentbuilderHelper::checkJson($component->addjoomla_modules)) ? json_decode($component->addjoomla_modules, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($component->addjoomla_modules))
|
||||
{
|
||||
$joomla_modules = array_map(function($array) use(&$component) {
|
||||
// only load the modules whose target association calls for it
|
||||
if (!isset($array['target']) || $array['target'] != 2)
|
||||
{
|
||||
return $this->setJoomlaModule($array['module'], $component);
|
||||
}
|
||||
return null;
|
||||
}, array_values($component->addjoomla_modules));
|
||||
}
|
||||
unset($component->addjoomla_modules);
|
||||
// get all plugins
|
||||
$component->addjoomla_plugins = (isset($component->addjoomla_plugins) && ComponentbuilderHelper::checkJson($component->addjoomla_plugins)) ? json_decode($component->addjoomla_plugins, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($component->addjoomla_plugins))
|
||||
{
|
||||
$joomla_plugins = array_map(function($array) use(&$component) {
|
||||
// only load the plugins whose target association calles for it
|
||||
// only load the plugins whose target association calls for it
|
||||
if (!isset($array['target']) || $array['target'] != 2)
|
||||
{
|
||||
return $this->setJoomlaPlugin($array['plugin'], $component);
|
||||
@ -4523,7 +4546,7 @@ class Get
|
||||
// check if the lib has already been set
|
||||
if (!isset($this->libraries[$id]))
|
||||
{
|
||||
// make sure we should continue and that the lib is not already bein loaded
|
||||
// make sure we should continue and that the lib is not already being loaded
|
||||
switch ($id)
|
||||
{
|
||||
case 1: // No Library
|
||||
@ -6218,6 +6241,576 @@ class Get
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla Modules IDs
|
||||
*
|
||||
* @return array of IDs on success
|
||||
*
|
||||
*/
|
||||
protected function getModuleIDs()
|
||||
{
|
||||
if (($addjoomla_modules = ComponentbuilderHelper::getVar('component_modules', $this->componentID, 'joomla_component', 'addjoomla_modules')) !== false)
|
||||
{
|
||||
$addjoomla_modules = (ComponentbuilderHelper::checkJson($addjoomla_modules)) ? json_decode($addjoomla_modules, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($addjoomla_modules))
|
||||
{
|
||||
$joomla_modules = array_filter(
|
||||
array_values($addjoomla_modules),
|
||||
function($array){
|
||||
// only load the modules whose target association call for it
|
||||
if (!isset($array['target']) || $array['target'] != 2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
// if we have values we return IDs
|
||||
if (ComponentbuilderHelper::checkArray($joomla_modules))
|
||||
{
|
||||
return array_map(function($array){
|
||||
return (int) $array['module'];
|
||||
}, $joomla_modules);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the Joomla modules
|
||||
*
|
||||
* @return true
|
||||
*
|
||||
*/
|
||||
public function setJoomlaModule($id, &$component)
|
||||
{
|
||||
if (isset($this->joomlaModules[$id]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a new query object.
|
||||
$query = $this->db->getQuery(true);
|
||||
|
||||
$query->select('a.*');
|
||||
$query->select(
|
||||
$this->db->quoteName(
|
||||
array(
|
||||
'f.addfiles',
|
||||
'f.addfolders',
|
||||
'f.addfilesfullpath',
|
||||
'f.addfoldersfullpath',
|
||||
'f.addurls',
|
||||
'u.version_update',
|
||||
'u.id'
|
||||
), array(
|
||||
'addfiles',
|
||||
'addfolders',
|
||||
'addfilesfullpath',
|
||||
'addfoldersfullpath',
|
||||
'addurls',
|
||||
'version_update',
|
||||
'version_update_id'
|
||||
)
|
||||
)
|
||||
);
|
||||
// from these tables
|
||||
$query->from('#__componentbuilder_joomla_module AS a');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_module_updates', 'u') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('u.joomla_module') . ')');
|
||||
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_joomla_module_files_folders_urls', 'f') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('f.joomla_module') . ')');
|
||||
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
|
||||
$query->where($this->db->quoteName('a.published') . ' >= 1');
|
||||
$this->db->setQuery($query);
|
||||
$this->db->execute();
|
||||
if ($this->db->getNumRows())
|
||||
{
|
||||
// get the module data
|
||||
$module = $this->db->loadObject();
|
||||
// tweak system to set stuff to the module domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
// set some keys
|
||||
$module->target_type = 'M0dU|3';
|
||||
$module->key = $module->id . '_' . $module->target_type;
|
||||
// update to point to module
|
||||
$this->target = $module->key;
|
||||
$this->lang = $module->key;
|
||||
// set version if not set
|
||||
if (empty($module->module_version))
|
||||
{
|
||||
$module->module_version = '1.0.0';
|
||||
}
|
||||
// set GUI mapper
|
||||
$guiMapper = array( 'table' => 'joomla_module', 'id' => (int) $id, 'type' => 'php');
|
||||
// update the name if it has dynamic values
|
||||
$module->name = $this->setPlaceholders($this->setDynamicValues($module->name), $this->placeholders);
|
||||
// update the name if it has dynamic values
|
||||
$module->code_name = ComponentbuilderHelper::safeClassFunctionName($module->name);
|
||||
// set official name
|
||||
$module->official_name = ucwords($module->name);
|
||||
// set langPrefix
|
||||
$this->langPrefix = 'MOD_' . strtoupper($module->code_name);
|
||||
// set lang prefix
|
||||
$module->lang_prefix = $this->langPrefix;
|
||||
// set module class name
|
||||
$module->class_helper_name = 'Mod' . ucfirst($module->code_name) . 'Helper';
|
||||
$module->class_data_name = 'Mod' . ucfirst($module->code_name) . 'Data';
|
||||
// set module install class name
|
||||
$module->installer_class_name = 'mod_' . ucfirst($module->code_name) . 'InstallerScript';
|
||||
// set module folder name
|
||||
$module->folder_name = 'mod_' . strtolower($module->code_name);
|
||||
// set the zip name
|
||||
$module->zip_name = $module->folder_name . '_v' . str_replace('.', '_', $module->module_version). '__J' . $this->joomlaVersion;
|
||||
// set module file name
|
||||
$module->file_name = $module->folder_name;
|
||||
// set official_name lang strings
|
||||
$this->setLangContent($module->key, $this->langPrefix, $module->official_name);
|
||||
// set some placeholder for this module
|
||||
$this->placeholders[$this->bbb . 'Module_name' . $this->ddd] = $module->official_name;
|
||||
$this->placeholders[$this->bbb . 'Module' . $this->ddd] = ucfirst($module->code_name);
|
||||
$this->placeholders[$this->bbb . 'module' . $this->ddd] = strtolower($module->code_name);
|
||||
$this->placeholders[$this->bbb . 'module.version' . $this->ddd] = $module->module_version;
|
||||
$this->placeholders[$this->bbb . 'module_version' . $this->ddd] = str_replace('.', '_', $module->module_version);
|
||||
// set description (TODO) add description field to module
|
||||
if (!isset($module->description) || !ComponentbuilderHelper::checkString($module->description))
|
||||
{
|
||||
$module->description = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->description = $this->setPlaceholders($this->setDynamicValues($module->description), $this->placeholders);
|
||||
$this->setLangContent($module->key, $module->lang_prefix . '_DESCRIPTION', $module->description);
|
||||
$module->description = '<p>' . $module->description . '</p>';
|
||||
}
|
||||
$module->xml_description = "<h1>" . $module->official_name . " (v." . $module->module_version . ")</h1> <div style='clear: both;'></div>" . $module->description . "<p>Created by <a href='" . trim($component->website) . "' target='_blank'>" . trim(JFilterOutput::cleanText($component->author)) . "</a><br /><small>Development started " . JFactory::getDate($module->created)->format("jS F, Y") . "</small></p>";
|
||||
// set xml description
|
||||
$this->setLangContent($module->key, $module->lang_prefix . '_XML_DESCRIPTION', $module->xml_description);
|
||||
// update the readme if set
|
||||
if ($module->addreadme == 1 && !empty($module->readme))
|
||||
{
|
||||
$module->readme = $this->setPlaceholders($this->setDynamicValues(base64_decode($module->readme)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->addreadme = 0;
|
||||
unset($module->readme);
|
||||
}
|
||||
// get the custom_get
|
||||
$module->custom_get = (isset($module->custom_get) && ComponentbuilderHelper::checkJson($module->custom_get)) ? json_decode($module->custom_get, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($module->custom_get))
|
||||
{
|
||||
$module->custom_get = $this->setGetData($module->custom_get, $module->key, $module->key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->custom_get = false;
|
||||
}
|
||||
// set helper class details
|
||||
if ($module->add_class_helper >= 1 && ComponentbuilderHelper::checkString($module->class_helper_code))
|
||||
{
|
||||
if ($module->add_class_helper_header == 1 && ComponentbuilderHelper::checkString($module->class_helper_header))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'class_helper_header';
|
||||
// base64 Decode code
|
||||
$module->class_helper_header = PHP_EOL . $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($module->class_helper_header)), $this->placeholders),
|
||||
$guiMapper
|
||||
) . PHP_EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->add_class_helper_header = 0;
|
||||
$module->class_helper_header = '';
|
||||
}
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'class_helper_code';
|
||||
// base64 Decode code
|
||||
$module->class_helper_code = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($module->class_helper_code)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
// set class type
|
||||
if ($module->add_class_helper == 2)
|
||||
{
|
||||
$module->class_helper_type = 'abstract class ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->class_helper_type = 'class ';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->add_class_helper = 0;
|
||||
$module->class_helper_code = '';
|
||||
$module->class_helper_header = '';
|
||||
}
|
||||
// base64 Decode mod_code
|
||||
if (isset($module->mod_code) && ComponentbuilderHelper::checkString($module->mod_code))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'mod_code';
|
||||
$module->mod_code = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($module->mod_code)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->mod_code = "// get the module class sfx";
|
||||
$module->mod_code .= PHP_EOL . "\$moduleclass_sfx = htmlspecialchars(\$params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');";
|
||||
$module->mod_code .= PHP_EOL . "// load the default Tmpl";
|
||||
$module->mod_code .= PHP_EOL . "require JModuleHelper::getLayoutPath('mod_" . strtolower($module->code_name) . "', \$params->get('layout', 'default'));";
|
||||
}
|
||||
// base64 Decode default header
|
||||
if (isset($module->default_header) && ComponentbuilderHelper::checkString($module->default_header))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'default_header';
|
||||
$module->default_header = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($module->default_header)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->default_header = '';
|
||||
}
|
||||
// base64 Decode default
|
||||
if (isset($module->default) && ComponentbuilderHelper::checkString($module->default))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = 'default';
|
||||
$module->default = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($module->default)), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->default = '<h1>No Tmpl set</h1>';
|
||||
}
|
||||
// start the config array
|
||||
$module->config_fields = array();
|
||||
// create the form arrays
|
||||
$module->form_files = array();
|
||||
$module->fieldsets_label = array();
|
||||
$module->fieldsets_paths = array();
|
||||
// set global fields rule to default component path
|
||||
$module->fields_rules_paths = 1;
|
||||
// set the fields data
|
||||
$module->fields = (isset($module->fields) && ComponentbuilderHelper::checkJson($module->fields)) ? json_decode($module->fields, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($module->fields))
|
||||
{
|
||||
// ket global key
|
||||
$key = $module->key;
|
||||
$dynamic_fields = array('fieldset' => 'basic', 'fields_name' => 'params', 'file' => 'config');
|
||||
foreach ($module->fields as $n => &$form)
|
||||
{
|
||||
if (isset($form['fields']) && ComponentbuilderHelper::checkArray($form['fields']))
|
||||
{
|
||||
// make sure the dynamic_field is set to dynamic_value by default
|
||||
foreach ($dynamic_fields as $dynamic_field => $dynamic_value)
|
||||
{
|
||||
if (!isset($form[$dynamic_field]) || !ComponentbuilderHelper::checkString($form[$dynamic_field]))
|
||||
{
|
||||
$form[$dynamic_field] = $dynamic_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ('fields_name' === $dynamic_field && strpos($form[$dynamic_field], '.') !== false)
|
||||
{
|
||||
$form[$dynamic_field] = $form[$dynamic_field];
|
||||
}
|
||||
else
|
||||
{
|
||||
$form[$dynamic_field] = ComponentbuilderHelper::safeString($form[$dynamic_field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if field is external form file
|
||||
if (!isset($form['module']) || $form['module'] != 1)
|
||||
{
|
||||
// now build the form key
|
||||
$unique = $form['file'] . $form['fields_name'] . $form['fieldset'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// now build the form key
|
||||
$unique = $form['fields_name'] . $form['fieldset'];
|
||||
}
|
||||
// set global fields rule path switchs
|
||||
if ($module->fields_rules_paths == 1 && isset($form['fields_rules_paths']) && $form['fields_rules_paths'] == 2)
|
||||
{
|
||||
$module->fields_rules_paths = 2;
|
||||
}
|
||||
// set where to path is pointing
|
||||
$module->fieldsets_paths[$unique] = $form['fields_rules_paths'];
|
||||
// add the label if set to lang
|
||||
if (isset($form['label']) && ComponentbuilderHelper::checkString($form['label']))
|
||||
{
|
||||
$module->fieldsets_label[$unique] = $this->setLang($form['label']);
|
||||
}
|
||||
// build the fields
|
||||
$form['fields'] = array_map(function($field) use ($key, $unique){
|
||||
// make sure the alias and title is 0
|
||||
$field['alias'] = 0;
|
||||
$field['title'] = 0;
|
||||
// set the field details
|
||||
$this->setFieldDetails($field, $key, $key, $unique);
|
||||
// update the default if set
|
||||
if (ComponentbuilderHelper::checkString($field['custom_value']) && isset($field['settings']))
|
||||
{
|
||||
if (($old_default = ComponentbuilderHelper::getBetween($field['settings']->xml, 'default="', '"', false)) !== false)
|
||||
{
|
||||
// replace old default
|
||||
$field['settings']->xml = str_replace('default="' . $old_default . '"', 'default="' . $field['custom_value'] . '"', $field['settings']->xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add the default (hmmm not ideal but okay it should work)
|
||||
$field['settings']->xml = 'default="' . $field['custom_value'] . '" ' . $field['settings']->xml;
|
||||
}
|
||||
}
|
||||
unset($field['custom_value']);
|
||||
// return field
|
||||
return $field;
|
||||
}, array_values($form['fields']));
|
||||
// check if field is external form file
|
||||
if (!isset($form['module']) || $form['module'] != 1)
|
||||
{
|
||||
// load the form file
|
||||
if (!isset($module->form_files[$form['file']]))
|
||||
{
|
||||
$module->form_files[$form['file']] = array();
|
||||
}
|
||||
if (!isset($module->form_files[$form['file']][$form['fields_name']]))
|
||||
{
|
||||
$module->form_files[$form['file']][$form['fields_name']] = array();
|
||||
}
|
||||
if (!isset($module->form_files[$form['file']][$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']] = array();
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
{
|
||||
// so first we lock the field name in
|
||||
$this->getFieldName($field, $module->key, $unique);
|
||||
// add the fields to the global form file builder
|
||||
$module->form_files[$form['file']][$form['fields_name']][$form['fieldset']][] = $field;
|
||||
}
|
||||
// remove form
|
||||
unset($module->fields[$n]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// load the config form
|
||||
if (!isset($module->config_fields[$form['fields_name']]))
|
||||
{
|
||||
$module->config_fields[$form['fields_name']] = array();
|
||||
}
|
||||
if (!isset($module->config_fields[$form['fields_name']][$form['fieldset']]))
|
||||
{
|
||||
$module->config_fields[$form['fields_name']][$form['fieldset']] = array();
|
||||
}
|
||||
// do some house cleaning (for fields)
|
||||
foreach ($form['fields'] as $field)
|
||||
{
|
||||
// so first we lock the field name in
|
||||
$this->getFieldName($field, $module->key, $unique);
|
||||
// add the fields to the config builder
|
||||
$module->config_fields[$form['fields_name']][$form['fieldset']][] = $field;
|
||||
}
|
||||
// remove form
|
||||
unset($module->fields[$n]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($module->fields[$n]);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($module->fields);
|
||||
// set the add targets
|
||||
$addArray = array('files' => 'files', 'folders' => 'folders', 'urls' => 'urls', 'filesfullpath' => 'files', 'foldersfullpath' => 'folders');
|
||||
foreach ($addArray as $addTarget => $targetHere)
|
||||
{
|
||||
// set the add target data
|
||||
$module->{'add' . $addTarget} = (isset($module->{'add' . $addTarget}) && ComponentbuilderHelper::checkJson($module->{'add' . $addTarget})) ? json_decode($module->{'add' . $addTarget}, true) : null;
|
||||
if (ComponentbuilderHelper::checkArray($module->{'add' . $addTarget}))
|
||||
{
|
||||
if (isset($module->{$targetHere}) && ComponentbuilderHelper::checkArray($module->{$targetHere}))
|
||||
{
|
||||
foreach ($module->{'add' . $addTarget} as $taget)
|
||||
{
|
||||
$module->{$targetHere}[] = $taget;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->{$targetHere} = array_values($module->{'add' . $addTarget});
|
||||
}
|
||||
}
|
||||
unset($module->{'add' . $addTarget});
|
||||
}
|
||||
// load the library
|
||||
if (!isset($this->libManager[$this->target]))
|
||||
{
|
||||
$this->libManager[$this->target] = array();
|
||||
}
|
||||
if (!isset($this->libManager[$this->target][$module->code_name]))
|
||||
{
|
||||
$this->libManager[$this->target][$module->code_name] = array();
|
||||
}
|
||||
// make sure json become array
|
||||
if (ComponentbuilderHelper::checkJson($module->libraries))
|
||||
{
|
||||
$module->libraries = json_decode($module->libraries, true);
|
||||
}
|
||||
// if we have an array add it
|
||||
if (ComponentbuilderHelper::checkArray($module->libraries))
|
||||
{
|
||||
foreach ($module->libraries as $library)
|
||||
{
|
||||
if (!isset($this->libManager[$this->target][$module->code_name][$library]))
|
||||
{
|
||||
if ($this->getMediaLibrary((int) $library))
|
||||
{
|
||||
$this->libManager[$this->target][$module->code_name][(int) $library] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (is_numeric($module->libraries) && !isset($this->libManager[$this->target][$module->code_name][(int) $module->libraries]))
|
||||
{
|
||||
if ($this->getMediaLibrary((int) $module->libraries))
|
||||
{
|
||||
$this->libManager[$this->target][$module->code_name][(int) $module->libraries] = true;
|
||||
}
|
||||
}
|
||||
// add PHP in module install
|
||||
$module->add_install_script = false;
|
||||
$addScriptMethods = array('php_preflight', 'php_postflight', 'php_method');
|
||||
$addScriptTypes = array('install', 'update', 'uninstall');
|
||||
foreach ($addScriptMethods as $scriptMethod)
|
||||
{
|
||||
foreach ($addScriptTypes as $scriptType)
|
||||
{
|
||||
if (isset($module->{'add_' . $scriptMethod . '_' . $scriptType}) && $module->{'add_' . $scriptMethod . '_' . $scriptType} == 1 && ComponentbuilderHelper::checkString($module->{$scriptMethod . '_' . $scriptType}))
|
||||
{
|
||||
// set GUI mapper field
|
||||
$guiMapper['field'] = $scriptMethod . '_' . $scriptType;
|
||||
$module->{$scriptMethod . '_' . $scriptType} = $this->setGuiCodePlaceholder(
|
||||
$this->setPlaceholders($this->setDynamicValues(base64_decode($module->{$scriptMethod . '_' . $scriptType})), $this->placeholders),
|
||||
$guiMapper
|
||||
);
|
||||
$module->add_install_script = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($module->{$scriptMethod . '_' . $scriptType});
|
||||
$module->{'add_' . $scriptMethod . '_' . $scriptType} = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// add_sql
|
||||
if ($module->add_sql == 1 && ComponentbuilderHelper::checkString($module->sql))
|
||||
{
|
||||
$module->sql = $this->setPlaceholders($this->setDynamicValues(base64_decode($module->sql)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($module->sql);
|
||||
$module->add_sql = 0;
|
||||
}
|
||||
// add_sql_uninstall
|
||||
if ($module->add_sql_uninstall == 1 && ComponentbuilderHelper::checkString($module->sql_uninstall))
|
||||
{
|
||||
$module->sql_uninstall = $this->setPlaceholders($this->setDynamicValues(base64_decode($module->sql_uninstall)), $this->placeholders);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($module->sql_uninstall);
|
||||
$module->add_sql_uninstall = 0;
|
||||
}
|
||||
// update the URL of the update_server if set
|
||||
if ($module->add_update_server == 1 && ComponentbuilderHelper::checkString($module->update_server_url))
|
||||
{
|
||||
$module->update_server_url = $this->setPlaceholders($this->setDynamicValues($module->update_server_url), $this->placeholders);
|
||||
}
|
||||
// add the update/sales server FTP details if that is the expected protocol
|
||||
$serverArray = array('update_server', 'sales_server');
|
||||
foreach ($serverArray as $server)
|
||||
{
|
||||
if ($module->{'add_' . $server} == 1 && is_numeric($module->{$server}) && $module->{$server} > 0)
|
||||
{
|
||||
// get the server protocol
|
||||
$module->{$server . '_protocol'} = ComponentbuilderHelper::getVar('server', (int) $module->{$server}, 'id', 'protocol');
|
||||
}
|
||||
else
|
||||
{
|
||||
$module->{$server} = 0;
|
||||
// only change this for sales server (update server can be added loacaly to the zip file)
|
||||
if ('sales_server' === $server)
|
||||
{
|
||||
$module->{'add_' . $server} = 0;
|
||||
}
|
||||
$module->{$server . '_protocol'} = 0;
|
||||
}
|
||||
}
|
||||
// set the update server stuff (TODO)
|
||||
// update_server_xml_path
|
||||
// update_server_xml_file_name
|
||||
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
|
||||
unset($this->placeholders[$this->bbb . 'Module_name' . $this->ddd]);
|
||||
unset($this->placeholders[$this->bbb . 'Module' . $this->ddd]);
|
||||
unset($this->placeholders[$this->bbb . 'module' . $this->ddd]);
|
||||
unset($this->placeholders[$this->bbb . 'module.version' . $this->ddd]);
|
||||
unset($this->placeholders[$this->bbb . 'module_version' . $this->ddd]);
|
||||
|
||||
$this->joomlaModules[$id] = $module;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the module xml template
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function getModuleXMLTemplate(&$module)
|
||||
{
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<extension type="module" version="3.8" client="site" method="upgrade">';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<name>' . $module->lang_prefix . '</name>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<creationDate>' . $this->hhh . 'BUILDDATE' . $this->hhh . '</creationDate>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<author>' . $this->hhh . 'AUTHOR' . $this->hhh . '</author>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<authorEmail>' . $this->hhh . 'AUTHOREMAIL' . $this->hhh . '</authorEmail>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<authorUrl>' . $this->hhh . 'AUTHORWEBSITE' . $this->hhh . '</authorUrl>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<copyright>' . $this->hhh . 'COPYRIGHT' . $this->hhh . '</copyright>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<license>' . $this->hhh . 'LICENSE' . $this->hhh . '</license>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<version>' . $module->module_version . '</version>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<description>' . $module->lang_prefix . '_XML_DESCRIPTION</description>';
|
||||
$xml .= $this->hhh . 'MAINXML' . $this->hhh;
|
||||
$xml .= PHP_EOL . '</extension>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the Joomla plugins IDs
|
||||
*
|
||||
@ -7512,7 +8105,23 @@ class Get
|
||||
// set the lang for both since we don't know what area is being targeted
|
||||
$_tmp = $this->lang;
|
||||
// set the lang based on target
|
||||
if (strpos($target, 'plugin') !== false)
|
||||
if (strpos($target, 'module') !== false)
|
||||
{
|
||||
// backup lang prefix
|
||||
$_tmp_lang_prefix = $this->langPrefix;
|
||||
// set the new lang prefix
|
||||
$this->langPrefix = strtoupper(str_replace('module', 'mod', $target));
|
||||
// now set the lang
|
||||
if (isset($this->langKeys[$this->langPrefix]))
|
||||
{
|
||||
$this->lang = $this->langKeys[$this->langPrefix];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->lang = 'module';
|
||||
}
|
||||
}
|
||||
elseif (strpos($target, 'plugin') !== false)
|
||||
{
|
||||
// backup lang prefix
|
||||
$_tmp_lang_prefix = $this->langPrefix;
|
||||
@ -7739,6 +8348,19 @@ class Get
|
||||
$localPaths['site'] = JPATH_ROOT . '/components/com_' . $this->componentCodeName;
|
||||
// TODO later to include the JS and CSS
|
||||
$localPaths['media'] = JPATH_ROOT . '/media/com_' . $this->componentCodeName;
|
||||
// Painfull but we need to folder paths for the linked modules
|
||||
if (($module_ids = $this->getModuleIDs()) !== false)
|
||||
{
|
||||
foreach ($module_ids as $module_id)
|
||||
{
|
||||
// get the module group and folder name
|
||||
// if (($path = $this->getModulePath($module_id)) !== false)
|
||||
// {
|
||||
// // set the path
|
||||
// $localPaths['module_' . str_replace('/', '_', $path)] = JPATH_ROOT . '/modules/' . $path;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// Painfull but we need to folder paths for the linked plugins
|
||||
if (($plugin_ids = $this->getPluginIDs()) !== false)
|
||||
{
|
||||
|
@ -371,6 +371,8 @@ class Structure extends Get
|
||||
$this->removeFolder($this->componentPath);
|
||||
// load the libraries files/folders and url's
|
||||
$this->setLibraries();
|
||||
// load the module files/folders and url's
|
||||
$this->buildModules();
|
||||
// load the plugin files/folders and url's
|
||||
$this->buildPlugins();
|
||||
// set the Joomla Version Data
|
||||
@ -416,6 +418,384 @@ class Structure extends Get
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Modules files, folders, url's and config
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
private function buildModules()
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
{
|
||||
// Trigger Event: jcb_ce_onBeforeSetModules
|
||||
$this->triggerEvent('jcb_ce_onBeforeBuildModules', array(&$this->componentContext, &$this->joomlaModules));
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module) && isset($module->folder_name)
|
||||
&& ComponentbuilderHelper::checkString($module->folder_name))
|
||||
{
|
||||
// module path
|
||||
$module->folder_path = $this->compilerPath . '/' . $module->folder_name;
|
||||
// set the module paths
|
||||
$this->dynamicPaths[$module->key] = $module->folder_path;
|
||||
// make sure there is no old build
|
||||
$this->removeFolder($module->folder_path);
|
||||
// creat the main component folder
|
||||
if (!JFolder::exists($module->folder_path))
|
||||
{
|
||||
JFolder::create($module->folder_path);
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name, $this->compilerPath);
|
||||
}
|
||||
// set main mod file
|
||||
$fileDetails = array('path' => $module->folder_path . '/' . $module->file_name . '.php',
|
||||
'name' => $module->file_name . '.php', 'zip' => $module->file_name . '.php');
|
||||
$this->writeFile($fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// main modfile' .
|
||||
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
|
||||
$this->hhh . 'MODCODE' . $this->hhh);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
// set custom_get
|
||||
if ($module->custom_get)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path . '/data.php',
|
||||
'name' => 'data.php', 'zip' => 'data.php');
|
||||
$this->writeFile($fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// get data file' .
|
||||
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL . PHP_EOL .
|
||||
'/**' . PHP_EOL .
|
||||
' * Module ' . $module->official_name . ' Data' . PHP_EOL .
|
||||
' */' . PHP_EOL .
|
||||
"class " . $module->class_data_name . ' extends \JObject' . PHP_EOL .
|
||||
"{" . $this->hhh . 'DYNAMICGETS' . $this->hhh . "}" . PHP_EOL);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
// set helper file
|
||||
if ($module->add_class_helper >= 1)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path . '/helper.php',
|
||||
'name' => 'helper.php', 'zip' => 'helper.php');
|
||||
$this->writeFile($fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// helper file' .
|
||||
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
|
||||
$this->hhh . 'HELPERCODE' . $this->hhh);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
// set main xml file
|
||||
$fileDetails = array('path' => $module->folder_path . '/' . $module->file_name . '.xml',
|
||||
'name' => $module->file_name . '.xml', 'zip' => $module->file_name . '.xml');
|
||||
$this->writeFile($fileDetails['path'], $this->getModuleXMLTemplate($module));
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
// set tmpl folder
|
||||
if (!JFolder::exists($module->folder_path . '/tmpl'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/tmpl');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . '/tmpl', $this->compilerPath);
|
||||
}
|
||||
// set default file
|
||||
$fileDetails = array('path' => $module->folder_path . '/tmpl/default.php',
|
||||
'name' => 'default.php', 'zip' => 'tmpl/default.php');
|
||||
$this->writeFile($fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// default tmpl' .
|
||||
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
|
||||
$this->hhh . 'MODDEFAULT' . $this->hhh);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
// set install script if needed
|
||||
if ($module->add_install_script)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path . '/script.php',
|
||||
'name' => 'script.php', 'zip' => 'script.php');
|
||||
$this->writeFile($fileDetails['path'],
|
||||
'<?php' . PHP_EOL . '// Script template' .
|
||||
PHP_EOL . $this->hhh . 'BOM' . $this->hhh . PHP_EOL .
|
||||
PHP_EOL . '// No direct access to this file' . PHP_EOL .
|
||||
"defined('_JEXEC') or die('Restricted access');" . PHP_EOL .
|
||||
$this->hhh . 'INSTALLCLASS' . $this->hhh);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
// set readme if found
|
||||
if ($module->addreadme)
|
||||
{
|
||||
$fileDetails = array('path' => $module->folder_path . '/README.md',
|
||||
'name' => 'README.md', 'zip' => 'README.md');
|
||||
$this->writeFile($fileDetails['path'], $module->readme);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
// set fields & rules folders if needed
|
||||
if (isset($module->fields_rules_paths) && $module->fields_rules_paths == 2)
|
||||
{
|
||||
// create fields folder
|
||||
if (!JFolder::exists($module->folder_path . '/fields'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/fields');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . '/fields', $this->compilerPath);
|
||||
}
|
||||
// create rules folder
|
||||
if (!JFolder::exists($module->folder_path . '/rules'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/rules');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . '/rules', $this->compilerPath);
|
||||
}
|
||||
}
|
||||
// set forms folder if needed
|
||||
if (isset($module->form_files) && ComponentbuilderHelper::checkArray($module->form_files))
|
||||
{
|
||||
// create forms folder
|
||||
if (!JFolder::exists($module->folder_path . '/forms'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/forms');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . '/forms', $this->compilerPath);
|
||||
}
|
||||
// set the template files
|
||||
foreach($module->form_files as $file => $fields)
|
||||
{
|
||||
// set file details
|
||||
$fileDetails = array('path' => $module->folder_path . '/forms/' . $file . '.xml',
|
||||
'name' => $file . '.xml', 'zip' => 'forms/' . $file . '.xml');
|
||||
// biuld basic XML
|
||||
$xml = '<?xml version="1.0" encoding="utf-8"?>';
|
||||
$xml .= PHP_EOL . '<!--' . $this->setLine(__LINE__) . ' default paths of ' . $file . ' form points to ' . $this->componentCodeName . ' -->';
|
||||
// search if we must add the component path
|
||||
$add_component_path = false;
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
if (!$add_component_path)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
if (!$add_component_path && isset($module->fieldsets_paths[$file . $field_name . $fieldset]) && $module->fieldsets_paths[$file . $field_name . $fieldset] == 1)
|
||||
{
|
||||
$add_component_path = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// only add if part of the component field types path is required
|
||||
if ($add_component_path)
|
||||
{
|
||||
$xml .= PHP_EOL . '<form';
|
||||
$xml .= PHP_EOL . $this->_t(1) . 'addrulepath="/administrator/components/com_' . $this->componentCodeName . '/models/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . 'addfieldpath="/administrator/components/com_' . $this->componentCodeName . '/models/fields"';
|
||||
$xml .= PHP_EOL . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . '<form>';
|
||||
}
|
||||
// add the fields
|
||||
foreach ($fields as $field_name => $fieldsets)
|
||||
{
|
||||
// check if we have an double fields naming set
|
||||
$field_name_inner = '';
|
||||
$field_name_outer = $field_name;
|
||||
if (strpos($field_name, '.') !== false)
|
||||
{
|
||||
$field_names = explode('.', $field_name);
|
||||
if (count((array) $field_names) == 2)
|
||||
{
|
||||
$field_name_outer = $field_names[0];
|
||||
$field_name_inner = $field_names[1];
|
||||
}
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fields name="' . $field_name_outer . '">';
|
||||
foreach ($fieldsets as $fieldset => $field)
|
||||
{
|
||||
// default to the field set name
|
||||
$label = $fieldset;
|
||||
if (isset($module->fieldsets_label[$file.$field_name.$fieldset]))
|
||||
{
|
||||
$label = $module->fieldsets_label[$file.$field_name.$fieldset];
|
||||
}
|
||||
// add path to module rules and custom fields
|
||||
if (isset($module->fieldsets_paths[$file.$field_name.$fieldset]) && $module->fieldsets_paths[$file.$field_name.$fieldset] == 2)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' default paths of ' . $fieldset . ' fieldset points to the module -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addrulepath="/modules/' . strtolower($module->code_name) . '/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addfieldpath="/modules/' . strtolower($module->code_name) . '/fields"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
// check if we have an inner field set
|
||||
if (ComponentbuilderHelper::checkString($field_name_inner))
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fields name="' . $field_name_inner . '">';
|
||||
}
|
||||
// add the placeholder of the fields
|
||||
$xml .= $this->hhh . 'FIELDSET_' . $file.$field_name.$fieldset . $this->hhh;
|
||||
// check if we have an inner field set
|
||||
if (ComponentbuilderHelper::checkString($field_name_inner))
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . '</form>';
|
||||
// add xml to file
|
||||
$this->writeFile($fileDetails['path'], $xml);
|
||||
$this->newFiles[$module->key][] = $fileDetails;
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
}
|
||||
// set SQL stuff if needed
|
||||
if ($module->add_sql || $module->add_sql_uninstall)
|
||||
{
|
||||
// create SQL folder
|
||||
if (!JFolder::exists($module->folder_path . '/sql'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/sql');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . '/sql', $this->compilerPath);
|
||||
}
|
||||
// create mysql folder
|
||||
if (!JFolder::exists($module->folder_path . '/sql/mysql'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/sql/mysql');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . '/sql/mysql', $this->compilerPath);
|
||||
}
|
||||
// now set the install file
|
||||
if ($module->add_sql)
|
||||
{
|
||||
$this->writeFile($module->folder_path . '/sql/mysql/install.sql', $module->sql);
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
// now set the uninstall file
|
||||
if ($module->add_sql_uninstall)
|
||||
{
|
||||
$this->writeFile($module->folder_path . '/sql/mysql/uninstall.sql', $module->sql_uninstall);
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
}
|
||||
// creat the language folder
|
||||
if (!JFolder::exists($module->folder_path . '/language'))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/language');
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
// also the lang tag
|
||||
if (!JFolder::exists($module->folder_path . '/language/' . $this->langTag))
|
||||
{
|
||||
JFolder::create($module->folder_path . '/language/' . $this->langTag);
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
}
|
||||
}
|
||||
// check if this lib has files
|
||||
if (isset($module->files) && ComponentbuilderHelper::checkArray($module->files))
|
||||
{
|
||||
// add to component files
|
||||
foreach ($module->files as $file)
|
||||
{
|
||||
// set the path finder
|
||||
$file['target_type'] = $module->target_type;
|
||||
$file['target_id'] = $module->id;
|
||||
$this->componentData->files[] = $file;
|
||||
}
|
||||
}
|
||||
// check if this lib has folders
|
||||
if (isset($module->folders) && ComponentbuilderHelper::checkArray($module->folders))
|
||||
{
|
||||
// add to component folders
|
||||
foreach ($module->folders as $folder)
|
||||
{
|
||||
// set the path finder
|
||||
$folder['target_type'] = $module->target_type;
|
||||
$folder['target_id'] = $module->id;
|
||||
$this->componentData->folders[] = $folder;
|
||||
}
|
||||
}
|
||||
// check if this module has urls
|
||||
if (isset($module->urls) && ComponentbuilderHelper::checkArray($module->urls))
|
||||
{
|
||||
// add to component urls
|
||||
foreach ($module->urls as $n => &$url)
|
||||
{
|
||||
// should we add the local folder
|
||||
if (isset($url['type']) && $url['type'] > 1 && isset($url['url'])
|
||||
&& ComponentbuilderHelper::checkString($url['url']))
|
||||
{
|
||||
// set file name
|
||||
$fileName = basename($url['url']);
|
||||
// get the file contents
|
||||
$data = ComponentbuilderHelper::getFileContents($url['url']);
|
||||
// build sub path
|
||||
if (strpos($fileName, '.js') !== false)
|
||||
{
|
||||
$path = '/js';
|
||||
}
|
||||
elseif (strpos($fileName, '.css') !== false)
|
||||
{
|
||||
$path = '/css';
|
||||
}
|
||||
else
|
||||
{
|
||||
$path = '';
|
||||
}
|
||||
// create sub media path if not set
|
||||
if (!JFolder::exists($module->folder_path .$path))
|
||||
{
|
||||
JFolder::create($module->folder_path . $path);
|
||||
// count the folder created
|
||||
$this->folderCount++;
|
||||
$this->indexHTML($module->folder_name . $path, $this->compilerPath);
|
||||
}
|
||||
// set the path to module file
|
||||
$url['path'] = $module->folder_path . $path . '/' . $fileName; // we need this for later
|
||||
// write data to path
|
||||
$this->writeFile($url['path'], $data);
|
||||
// count the file created
|
||||
$this->fileCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Plugins files, folders, url's and config
|
||||
*
|
||||
|
@ -2586,16 +2586,25 @@ class Interpretation extends Fields
|
||||
{
|
||||
$methods = '';
|
||||
// then set the needed custom methods
|
||||
if (ComponentbuilderHelper::checkArray($main_view['settings']->custom_get))
|
||||
if (ComponentbuilderHelper::checkArray($main_view) && isset($main_view['settings']) && ComponentbuilderHelper::checkObject($main_view['settings']) && isset($main_view['settings']->custom_get))
|
||||
{
|
||||
$_dynamic_get = $main_view['settings']->custom_get;
|
||||
}
|
||||
elseif (ComponentbuilderHelper::checkObject($main_view) && isset($main_view->custom_get))
|
||||
{
|
||||
$_dynamic_get = $main_view->custom_get;
|
||||
}
|
||||
// check if we have an array
|
||||
if (isset($_dynamic_get) && ComponentbuilderHelper::checkArray($_dynamic_get))
|
||||
{
|
||||
// start dynamic build
|
||||
foreach ($main_view['settings']->custom_get as $view)
|
||||
foreach ($_dynamic_get as $view)
|
||||
{
|
||||
// fix alias to use in code
|
||||
$view->code = ComponentbuilderHelper::safeString($code);
|
||||
$view->Code = ComponentbuilderHelper::safeString($view->code, 'F');
|
||||
$view->CODE = ComponentbuilderHelper::safeString($view->code, 'U');
|
||||
$main = '';
|
||||
$main = '';
|
||||
if ($view->gettype == 3)
|
||||
{
|
||||
// SITE_GET_ITEM <<<DYNAMIC>>>
|
||||
@ -2664,7 +2673,10 @@ class Interpretation extends Fields
|
||||
}
|
||||
}
|
||||
// load uikit get method
|
||||
$methods .= $this->setUikitGetMethod();
|
||||
if (ComponentbuilderHelper::checkArray($main_view) && isset($main_view['settings']))
|
||||
{
|
||||
$methods .= $this->setUikitGetMethod();
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
@ -4001,26 +4013,40 @@ class Interpretation extends Fields
|
||||
|
||||
public function setLibrariesLoader($view)
|
||||
{
|
||||
// check call sig
|
||||
if (isset($view['settings']) && isset($view['settings']->code))
|
||||
{
|
||||
$code = $view['settings']->code;
|
||||
$view_active = true;
|
||||
}
|
||||
elseif (isset($view->code_name))
|
||||
{
|
||||
$code = $view->code_name;
|
||||
$view_active = false;
|
||||
}
|
||||
// reset bucket
|
||||
$setter = '';
|
||||
// allways load these in
|
||||
$setter .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " always make sure jquery is loaded.";
|
||||
$setter .= PHP_EOL . $this->_t(2) . "JHtml::_('jquery.framework');";
|
||||
$setter .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Load the header checker class.";
|
||||
if ($this->target === 'site')
|
||||
if ($view_active)
|
||||
{
|
||||
$setter .= PHP_EOL . $this->_t(2) . "require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );";
|
||||
$setter .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " always make sure jquery is loaded.";
|
||||
$setter .= PHP_EOL . $this->_t(2) . "JHtml::_('jquery.framework');";
|
||||
$setter .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Load the header checker class.";
|
||||
if ($this->target === 'site')
|
||||
{
|
||||
$setter .= PHP_EOL . $this->_t(2) . "require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );";
|
||||
}
|
||||
else
|
||||
{
|
||||
$setter .= PHP_EOL . $this->_t(2) . "require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );";
|
||||
}
|
||||
$setter .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Initialize the header checker.";
|
||||
$setter .= PHP_EOL . $this->_t(2) . "\$HeaderCheck = new " . $this->componentCodeName . "HeaderCheck;";
|
||||
}
|
||||
else
|
||||
{
|
||||
$setter .= PHP_EOL . $this->_t(2) . "require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );";
|
||||
}
|
||||
$setter .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Initialize the header checker.";
|
||||
$setter .= PHP_EOL . $this->_t(2) . "\$HeaderCheck = new " . $this->componentCodeName . "HeaderCheck;";
|
||||
// check if this view should get libraries
|
||||
if (isset($this->libManager[$this->target][$view['settings']->code]) && ComponentbuilderHelper::checkArray($this->libManager[$this->target][$view['settings']->code]))
|
||||
if (isset($this->libManager[$this->target][$code]) && ComponentbuilderHelper::checkArray($this->libManager[$this->target][$code]))
|
||||
{
|
||||
foreach ($this->libManager[$this->target][$view['settings']->code] as $id => $true)
|
||||
foreach ($this->libManager[$this->target][$code] as $id => $true)
|
||||
{
|
||||
if (isset($this->libraries[$id]) && ComponentbuilderHelper::checkObject($this->libraries[$id]) && isset($this->libraries[$id]->document) && ComponentbuilderHelper::checkString($this->libraries[$id]->document))
|
||||
{
|
||||
@ -4033,6 +4059,11 @@ class Interpretation extends Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
// convert back to $document if module call (oops :)
|
||||
if (!$view_active)
|
||||
{
|
||||
return str_replace('$this->document->', '$document->', $setter);
|
||||
}
|
||||
return $setter;
|
||||
}
|
||||
|
||||
@ -16641,6 +16672,220 @@ function vdm_dkim() {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
public function getModCode(&$module)
|
||||
{
|
||||
return PHP_EOL . $module->mod_code . PHP_EOL;
|
||||
}
|
||||
|
||||
public function getModDefault(&$module)
|
||||
{
|
||||
return PHP_EOL . $module->default_header . PHP_EOL . '?>' . PHP_EOL . $module->default . PHP_EOL;
|
||||
}
|
||||
|
||||
public function getModHelperCode(&$module)
|
||||
{
|
||||
return
|
||||
$module->class_helper_header . PHP_EOL .
|
||||
$module->class_helper_type . $module->class_helper_name . PHP_EOL . '{' . PHP_EOL .
|
||||
$module->class_helper_code . PHP_EOL .
|
||||
"}" . PHP_EOL;
|
||||
}
|
||||
|
||||
public function getModuleMainXML(&$module)
|
||||
{
|
||||
// set the custom table key
|
||||
$dbkey = 'yyy';
|
||||
// build the xml
|
||||
$xml = '';
|
||||
// search if we must add the component path
|
||||
$add_component_path = false;
|
||||
// build the config fields
|
||||
$config_fields = array();
|
||||
if (isset($module->config_fields) && ComponentbuilderHelper::checkArray($module->config_fields))
|
||||
{
|
||||
foreach ($module->config_fields as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// get the field set
|
||||
$xmlFields = $this->getExtensionFieldsetXML($module, $fields, $dbkey);
|
||||
// make sure the xml is set and a string
|
||||
if (isset($xmlFields) && ComponentbuilderHelper::checkString($xmlFields))
|
||||
{
|
||||
$config_fields[$field_name . $fieldset] = $xmlFields;
|
||||
}
|
||||
$dbkey++;
|
||||
// check if the fieldset path requiers component paths
|
||||
if (!$add_component_path && isset($module->fieldsets_paths[$field_name . $fieldset]) && $module->fieldsets_paths[$field_name . $fieldset] == 1)
|
||||
{
|
||||
$add_component_path = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// switch to add the xml
|
||||
$addLang = false;
|
||||
// now build the language files
|
||||
if (isset($this->langContent[$module->key]))
|
||||
{
|
||||
$lang = array_map(function ($langstring, $placeholder)
|
||||
{
|
||||
return $placeholder . '="' . $langstring . '"';
|
||||
}, $this->langContent[$module->key], array_keys($this->langContent[$module->key]));
|
||||
// add to language file
|
||||
$this->writeFile($module->folder_path . '/language/' . $this->langTag . '/' . $this->langTag . '.' . $module->file_name . '.ini', implode(PHP_EOL, $lang));
|
||||
$this->writeFile($module->folder_path . '/language/' . $this->langTag . '/' . $this->langTag . '.' . $module->file_name . '.sys.ini', implode(PHP_EOL, $lang));
|
||||
// set the line counter
|
||||
$this->lineCount = $this->lineCount + count((array) $lang);
|
||||
unset($lang);
|
||||
// trigger the xml
|
||||
$addLang = true;
|
||||
}
|
||||
// get all files and folders in module folder
|
||||
$files = JFolder::files($module->folder_path);
|
||||
$folders = JFolder::folders($module->folder_path);
|
||||
// the files/folders to ignore
|
||||
$ignore = array('sql', 'language', 'script.php', $module->file_name . '.xml', $module->file_name . '.php');
|
||||
// should the scriptfile be added
|
||||
if ($module->add_install_script)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Scripts to run on installation -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<scriptfile>script.php</scriptfile>';
|
||||
}
|
||||
// should the sql install be added
|
||||
if ($module->add_sql)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Runs on install; New in Joomla 1.5 -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<install>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<sql>';
|
||||
$xml .= PHP_EOL . $this->_t(3) . '<file driver="mysql" charset="utf8">sql/mysql/install.sql</file>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<sql>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</install>';
|
||||
}
|
||||
// should the sql uninstall be added
|
||||
if ($module->add_sql_uninstall)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Runs on uninstall; New in Joomla 1.5 -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<uninstall>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<sql>';
|
||||
$xml .= PHP_EOL . $this->_t(3) . '<file driver="mysql" charset="utf8">sql/mysql/uninstall.sql</file>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<sql>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</uninstall>';
|
||||
}
|
||||
// should the language xml be added
|
||||
if ($addLang)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Language files -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<languages folder="language">';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<language tag="en-GB">' . $this->langTag . '/' . $this->langTag . '.' . $module->file_name . '.ini</language>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<language tag="en-GB">' . $this->langTag . '/' . $this->langTag . '.' . $module->file_name . '.sys.ini</language>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</languages>';
|
||||
}
|
||||
// add the module files
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Model files -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<files>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<filename module="' . $module->file_name . '">' . $module->file_name . '.php</filename>';
|
||||
// add other files found
|
||||
if (ComponentbuilderHelper::checkArray($files))
|
||||
{
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// only add what is not ignored
|
||||
if (!in_array($file, $ignore))
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<filename>' . $file . '</filename>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// add language folder
|
||||
if ($addLang)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<folder>language</folder>';
|
||||
}
|
||||
// add sql folder
|
||||
if ($module->add_sql || $module->add_sql_uninstall)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<folder>sql</folder>';
|
||||
}
|
||||
// add other files found
|
||||
if (ComponentbuilderHelper::checkArray($folders))
|
||||
{
|
||||
foreach ($folders as $folder)
|
||||
{
|
||||
// only add what is not ignored
|
||||
if (!in_array($folder, $ignore))
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<folder>' . $folder . '</folder>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</files>';
|
||||
// now add the Config Params if needed
|
||||
if (ComponentbuilderHelper::checkArray($config_fields))
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Config parameter -->';
|
||||
// only add if part of the component field types path is required
|
||||
if ($add_component_path)
|
||||
{
|
||||
// add path to module rules and custom fields
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<config';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addrulepath="/administrator/components/com_' . $this->componentCodeName . '/modules/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addfieldpath="/administrator/components/com_' . $this->componentCodeName . '/modules/fields"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<config>';
|
||||
}
|
||||
// add the fields
|
||||
foreach ($module->config_fields as $field_name => $fieldsets)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fields name="' . $field_name . '">';
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// default to the field set name
|
||||
$label = $fieldset;
|
||||
if (isset($module->fieldsets_label[$field_name.$fieldset]))
|
||||
{
|
||||
$label = $module->fieldsets_label[$field_name.$fieldset];
|
||||
}
|
||||
// add path to module rules and custom fields
|
||||
if (isset($module->fieldsets_paths[$field_name . $fieldset]) && $module->fieldsets_paths[$field_name . $fieldset] == 2)
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' default paths of ' . $fieldset . ' fieldset points to the module -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addrulepath="/modules/' . $module->file_name . '/rules"';
|
||||
$xml .= PHP_EOL . $this->_t(2) . 'addfieldpath="/modules/' . $module->file_name . '/fields"';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="' . $fieldset . '" label="' . $label . '">';
|
||||
}
|
||||
// load the fields
|
||||
if (isset($config_fields[$field_name.$fieldset]))
|
||||
{
|
||||
$xml .= $config_fields[$field_name.$fieldset];
|
||||
unset($config_fields[$field_name.$fieldset]);
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fieldset>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</fields>';
|
||||
}
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</config>';
|
||||
}
|
||||
// set update server if found
|
||||
if ($module->add_update_server)
|
||||
{
|
||||
$xml .= PHP_EOL . PHP_EOL . $this->_t(1) . '<!--' . $this->setLine(__LINE__) . ' Update servers -->';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '<updateservers>';
|
||||
$xml .= PHP_EOL . $this->_t(2) . '<server type="extension" priority="1" name="' . $module->official_name . '">' . $module->update_server_url . '</server>';
|
||||
$xml .= PHP_EOL . $this->_t(1) . '</updateservers>';
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
public function getPluginMainClass(&$plugin)
|
||||
{
|
||||
return
|
||||
@ -16672,7 +16917,7 @@ function vdm_dkim() {
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// get the field set
|
||||
$xmlFields = $this->getPluginFieldsetXML($plugin, $fields, $dbkey);
|
||||
$xmlFields = $this->getExtensionFieldsetXML($plugin, $fields, $dbkey);
|
||||
// make sure the xml is set and a string
|
||||
if (isset($xmlFields) && ComponentbuilderHelper::checkString($xmlFields))
|
||||
{
|
||||
@ -16850,7 +17095,7 @@ function vdm_dkim() {
|
||||
return $xml;
|
||||
}
|
||||
|
||||
public function getPluginFieldsetXML(&$plugin, &$fields, $dbkey = 'zz')
|
||||
public function getExtensionFieldsetXML(&$extension, &$fields, $dbkey = 'zz')
|
||||
{
|
||||
// set some defaults
|
||||
$view = '';
|
||||
@ -16866,12 +17111,12 @@ function vdm_dkim() {
|
||||
if ($this->fieldBuilderType == 1)
|
||||
{
|
||||
// string manipulation
|
||||
$xmlField = $this->setDynamicField($field, $view, $viewType, $plugin->lang_prefix, $plugin->key, $plugin->key, $this->globalPlaceholders, $dbkey, false);
|
||||
$xmlField = $this->setDynamicField($field, $view, $viewType, $extension->lang_prefix, $extension->key, $extension->key, $this->globalPlaceholders, $dbkey, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// simpleXMLElement class
|
||||
$newxmlField = $this->setDynamicField($field, $view, $viewType, $plugin->lang_prefix, $plugin->key, $plugin->key, $this->globalPlaceholders, $dbkey, false);
|
||||
$newxmlField = $this->setDynamicField($field, $view, $viewType, $extension->lang_prefix, $extension->key, $extension->key, $this->globalPlaceholders, $dbkey, false);
|
||||
if (isset($newxmlField->fieldXML))
|
||||
{
|
||||
$xmlField = dom_import_simplexml($newxmlField->fieldXML);
|
||||
@ -16888,24 +17133,24 @@ function vdm_dkim() {
|
||||
return $fieldset;
|
||||
}
|
||||
|
||||
public function getPluginInstallClass(&$plugin)
|
||||
public function getExtensionInstallClass(&$extension)
|
||||
{
|
||||
// yes we are adding it
|
||||
$script = PHP_EOL . '/**';
|
||||
$script .= PHP_EOL . ' * ' . $plugin->official_name . ' script file.';
|
||||
$script .= PHP_EOL . ' * ' . $extension->official_name . ' script file.';
|
||||
$script .= PHP_EOL . ' *';
|
||||
$script .= PHP_EOL . ' * @package ' . $plugin->class_name;
|
||||
$script .= PHP_EOL . ' * @package ' . $extension->class_name;
|
||||
$script .= PHP_EOL . ' */';
|
||||
$script .= PHP_EOL . 'class ' . $plugin->installer_class_name;
|
||||
$script .= PHP_EOL . 'class ' . $extension->installer_class_name;
|
||||
$script .= PHP_EOL . '{';
|
||||
// set constructor
|
||||
if (isset($plugin->add_php_script_construct)
|
||||
&& $plugin->add_php_script_construct == 1
|
||||
&& ComponentbuilderHelper::checkString($plugin->php_script_construct))
|
||||
if (isset($extension->add_php_script_construct)
|
||||
&& $extension->add_php_script_construct == 1
|
||||
&& ComponentbuilderHelper::checkString($extension->php_script_construct))
|
||||
{
|
||||
$script .= $this->setInstallMethodScript('construct', $plugin->php_script_construct);
|
||||
$script .= $this->setInstallMethodScript('construct', $extension->php_script_construct);
|
||||
}
|
||||
// add PHP in plugin install
|
||||
// add PHP in extension install
|
||||
$addScriptMethods = array('php_preflight', 'php_postflight', 'php_method');
|
||||
$addScriptTypes = array('install', 'update', 'uninstall', 'discover_install');
|
||||
// set some buckets for sorting
|
||||
@ -16921,18 +17166,18 @@ function vdm_dkim() {
|
||||
{
|
||||
foreach ($addScriptTypes as $scriptType)
|
||||
{
|
||||
if (isset($plugin->{'add_' . $scriptMethod . '_' . $scriptType})
|
||||
&& $plugin->{'add_' . $scriptMethod . '_' . $scriptType} == 1
|
||||
&& ComponentbuilderHelper::checkString($plugin->{$scriptMethod . '_' . $scriptType}))
|
||||
if (isset($extension->{'add_' . $scriptMethod . '_' . $scriptType})
|
||||
&& $extension->{'add_' . $scriptMethod . '_' . $scriptType} == 1
|
||||
&& ComponentbuilderHelper::checkString($extension->{$scriptMethod . '_' . $scriptType}))
|
||||
{
|
||||
// add to the main methods
|
||||
if ('php_method' === $scriptMethod)
|
||||
{
|
||||
${'function_' . $scriptType}[] = $plugin->{$scriptMethod . '_' . $scriptType};
|
||||
${'function_' . $scriptType}[] = $extension->{$scriptMethod . '_' . $scriptType};
|
||||
}
|
||||
else
|
||||
{
|
||||
${'function_' . $scriptMethod}[$scriptType][] = $plugin->{$scriptMethod . '_' . $scriptType};
|
||||
${'function_' . $scriptMethod}[$scriptType][] = $extension->{$scriptMethod . '_' . $scriptType};
|
||||
${'has_' . $scriptMethod} = true;
|
||||
}
|
||||
}
|
||||
|
@ -1029,17 +1029,65 @@ class Infusion extends Interpretation
|
||||
$this->fileContentStatic[$this->hhh . 'README' . $this->hhh] = $this->componentData->readme;
|
||||
}
|
||||
|
||||
// infuze plugin data if set
|
||||
// tweak system to set stuff to the module domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
// infuse module data if set
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaModules))
|
||||
{
|
||||
foreach ($this->joomlaModules as $module)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($module))
|
||||
{
|
||||
$this->target = $module->key;
|
||||
$this->lang = $module->key;
|
||||
$this->langPrefix = $module->lang_prefix;
|
||||
// MODCODE
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'MODCODE' . $this->hhh] = $this->getModCode($module);
|
||||
// DYNAMICGET
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'DYNAMICGETS' . $this->hhh] = $this->setCustomViewCustomMethods($module, $module->key);
|
||||
// HELPERCODE
|
||||
if ($module->add_class_helper >= 1)
|
||||
{
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'HELPERCODE' . $this->hhh] = $this->getModHelperCode($module);
|
||||
}
|
||||
// MODDEFAULT
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'MODDEFAULT' . $this->hhh] = $this->getModDefault($module);
|
||||
// only add install script if needed
|
||||
if ($module->add_install_script)
|
||||
{
|
||||
// INSTALLCLASS
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'INSTALLCLASS' . $this->hhh] = $this->getExtensionInstallClass($module);
|
||||
}
|
||||
// FIELDSET
|
||||
if (isset($module->form_files) && ComponentbuilderHelper::checkArray($module->form_files))
|
||||
{
|
||||
foreach($module->form_files as $file => $files)
|
||||
{
|
||||
foreach ($files as $field_name => $fieldsets)
|
||||
{
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// FIELDSET_ . $file.$field_name.$fieldset
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'FIELDSET_' . $file.$field_name.$fieldset . $this->hhh] =
|
||||
$this->getExtensionFieldsetXML($module, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// MAINXML
|
||||
$this->fileContentDynamic[$module->key][$this->hhh . 'MAINXML' . $this->hhh] = $this->getModuleMainXML($module);
|
||||
}
|
||||
}
|
||||
}
|
||||
// infuse plugin data if set
|
||||
if (ComponentbuilderHelper::checkArray($this->joomlaPlugins))
|
||||
{
|
||||
foreach ($this->joomlaPlugins as $plugin)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkObject($plugin))
|
||||
{
|
||||
// tweak system to set stuff to the plugin domain
|
||||
$_backup_target = $this->target;
|
||||
$_backup_lang = $this->lang;
|
||||
$_backup_langPrefix = $this->langPrefix;
|
||||
$this->target = $plugin->key;
|
||||
$this->lang = $plugin->key;
|
||||
$this->langPrefix = $plugin->lang_prefix;
|
||||
@ -1049,7 +1097,7 @@ class Infusion extends Interpretation
|
||||
if ($plugin->add_install_script)
|
||||
{
|
||||
// INSTALLCLASS
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'INSTALLCLASS' . $this->hhh] = $this->getPluginInstallClass($plugin);
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'INSTALLCLASS' . $this->hhh] = $this->getExtensionInstallClass($plugin);
|
||||
}
|
||||
// FIELDSET
|
||||
if (isset($plugin->form_files) && ComponentbuilderHelper::checkArray($plugin->form_files))
|
||||
@ -1061,21 +1109,21 @@ class Infusion extends Interpretation
|
||||
foreach ($fieldsets as $fieldset => $fields)
|
||||
{
|
||||
// FIELDSET_ . $file.$field_name.$fieldset
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'FIELDSET_' . $file.$field_name.$fieldset . $this->hhh] =
|
||||
$this->getPluginFieldsetXML($plugin, $fields);
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'FIELDSET_' . $file.$field_name.$fieldset . $this->hhh] =
|
||||
$this->getExtensionFieldsetXML($plugin, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// MAINXML
|
||||
$this->fileContentDynamic[$plugin->key][$this->hhh . 'MAINXML' . $this->hhh] = $this->getPluginMainXML($plugin);
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
}
|
||||
}
|
||||
}
|
||||
// rest globals
|
||||
$this->target = $_backup_target;
|
||||
$this->lang = $_backup_lang;
|
||||
$this->langPrefix = $_backup_langPrefix;
|
||||
|
||||
// Trigger Event: jcb_ce_onAfterBuildFilesContent
|
||||
$this->triggerEvent('jcb_ce_onAfterBuildFilesContent', array(&$this->componentContext, &$this->componentData, &$this->fileContentStatic, &$this->fileContentDynamic, &$this->placeholders, &$this->hhh));
|
||||
|
Reference in New Issue
Block a user