2023-04-13 15:44:10 +00:00
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Config Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Config
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Config $config;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The EventInterface Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Event
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
protected Event $event;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Placeholder Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Placeholder
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Placeholder $placeholder;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Dispenser Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Dispenser
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Dispenser $dispenser;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Customtabs Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Customtabs
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Customtabs $customtabs;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Tabs Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Tabs
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Tabs $tabs;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Fields Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Fields
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Fields $fields;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Historyadminview Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var History
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
protected History $history;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Permissions Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Permissions
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Permissions $permissions;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Conditions Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Conditions
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Conditions $conditions;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Relations Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Relations
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Relations $relations;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Linkedviews Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Linkedviews
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Linkedviews $linkedviews;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Javascriptadminview Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Javascript
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
protected Javascript $javascript;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Cssadminview Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Css
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
protected Css $css;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Phpadminview Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Php
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
protected Php $php;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Custombuttons Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Custombuttons
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Custombuttons $custombuttons;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Customimportscripts Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Customimportscripts
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Customimportscripts $customimportscripts;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Ajaxadmin Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Ajax
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
protected Ajax $ajax;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Customalias Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Customalias
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Customalias $customalias;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Sql Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Sql
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Sql $sql;
|
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* The Mysqlsettings Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @var Mysqlsettings
|
2023-04-13 15:44:10 +00:00
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected Mysqlsettings $mysqlsettings;
|
|
|
|
|
2023-10-04 18:28:29 +00:00
|
|
|
/**
|
|
|
|
* The SiteEditView Class.
|
|
|
|
*
|
|
|
|
* @var SiteEditView
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
protected SiteEditView $siteeditview;
|
|
|
|
|
2023-04-13 15:44:10 +00:00
|
|
|
/**
|
|
|
|
* Database object to query local DB
|
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
**/
|
2024-01-27 07:09:33 +00:00
|
|
|
protected $db;
|
2023-04-13 15:44:10 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-04 18:28:29 +00:00
|
|
|
* Constructor.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
2023-10-04 18:28:29 +00:00
|
|
|
* @param Config $config The Config Class.
|
|
|
|
* @param Event $event The EventInterface Class.
|
|
|
|
* @param Placeholder $placeholder The Placeholder Class.
|
|
|
|
* @param Dispenser $dispenser The Dispenser Class.
|
|
|
|
* @param Customtabs $customtabs The Customtabs Class.
|
|
|
|
* @param Tabs $tabs The Tabs Class.
|
|
|
|
* @param Fields $fields The Fields Class.
|
|
|
|
* @param History $history The Historyadminview Class.
|
|
|
|
* @param Permissions $permissions The Permissions Class.
|
|
|
|
* @param Conditions $conditions The Conditions Class.
|
|
|
|
* @param Relations $relations The Relations Class.
|
|
|
|
* @param Linkedviews $linkedviews The Linkedviews Class.
|
|
|
|
* @param Javascript $javascript The Javascriptadminview Class.
|
|
|
|
* @param Css $css The Cssadminview Class.
|
|
|
|
* @param Php $php The Phpadminview Class.
|
|
|
|
* @param Custombuttons $custombuttons The Custombuttons Class.
|
|
|
|
* @param Customimportscripts $customimportscripts The Customimportscripts Class.
|
|
|
|
* @param Ajax $ajax The Ajaxadmin Class.
|
|
|
|
* @param Customalias $customalias The Customalias Class.
|
|
|
|
* @param Sql $sql The Sql Class.
|
|
|
|
* @param Mysqlsettings $mysqlsettings The Mysqlsettings Class.
|
|
|
|
* @param SiteEditView $siteeditview The SiteEditView Class.
|
2023-04-13 15:44:10 +00:00
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
2023-10-04 18:28:29 +00:00
|
|
|
public function __construct(Config $config, Event $event, Placeholder $placeholder, Dispenser $dispenser, Customtabs $customtabs, Tabs $tabs, Fields $fields,
|
|
|
|
History $history, Permissions $permissions, Conditions $conditions, Relations $relations, Linkedviews $linkedviews, Javascript $javascript,
|
|
|
|
Css $css, Php $php, Custombuttons $custombuttons, Customimportscripts $customimportscripts, Ajax $ajax, Customalias $customalias, Sql $sql,
|
2024-01-27 07:09:33 +00:00
|
|
|
Mysqlsettings $mysqlsettings, SiteEditView $siteeditview)
|
2023-04-13 15:44:10 +00:00
|
|
|
{
|
2023-10-04 18:28:29 +00:00
|
|
|
$this->config = $config;
|
|
|
|
$this->event = $event;
|
|
|
|
$this->placeholder = $placeholder;
|
|
|
|
$this->dispenser = $dispenser;
|
|
|
|
$this->customtabs = $customtabs;
|
|
|
|
$this->tabs = $tabs;
|
|
|
|
$this->fields = $fields;
|
|
|
|
$this->history = $history;
|
|
|
|
$this->permissions = $permissions;
|
|
|
|
$this->conditions = $conditions;
|
|
|
|
$this->relations = $relations;
|
|
|
|
$this->linkedviews = $linkedviews;
|
|
|
|
$this->javascript = $javascript;
|
|
|
|
$this->css = $css;
|
|
|
|
$this->php = $php;
|
|
|
|
$this->custombuttons = $custombuttons;
|
|
|
|
$this->customimportscripts = $customimportscripts;
|
|
|
|
$this->ajax = $ajax;
|
|
|
|
$this->customalias = $customalias;
|
|
|
|
$this->sql = $sql;
|
|
|
|
$this->mysqlsettings = $mysqlsettings;
|
|
|
|
$this->siteeditview = $siteeditview;
|
2024-01-27 07:09:33 +00:00
|
|
|
$this->db = Factory::getDbo();
|
2023-04-13 15:44:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Admin View Data
|
|
|
|
*
|
|
|
|
* @param int $id The view ID
|
|
|
|
*
|
|
|
|
* @return object|null The view data
|
|
|
|
* @since 3.2.0
|
|
|
|
*/
|
|
|
|
public function get(int $id): ?object
|
|
|
|
{
|
|
|
|
if (!isset($this->data[$id]))
|
|
|
|
{
|
|
|
|
// Create a new query object.
|
|
|
|
$query = $this->db->getQuery(true);
|
|
|
|
|
|
|
|
$query->select('a.*');
|
|
|
|
$query->select(
|
|
|
|
$this->db->quoteName(
|
|
|
|
array(
|
|
|
|
'b.addfields',
|
|
|
|
'b.id',
|
|
|
|
'c.addconditions',
|
|
|
|
'c.id',
|
|
|
|
'r.addrelations',
|
|
|
|
't.tabs'
|
|
|
|
), array(
|
|
|
|
'addfields',
|
|
|
|
'addfields_id',
|
|
|
|
'addconditions',
|
|
|
|
'addconditions_id',
|
|
|
|
'addrelations',
|
|
|
|
'customtabs'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$query->from('#__componentbuilder_admin_view AS a');
|
|
|
|
$query->join(
|
|
|
|
'LEFT',
|
|
|
|
$this->db->quoteName('#__componentbuilder_admin_fields', 'b')
|
|
|
|
. ' ON (' . $this->db->quoteName('a.id') . ' = '
|
|
|
|
. $this->db->quoteName('b.admin_view') . ')'
|
|
|
|
);
|
|
|
|
|
|
|
|
$query->join(
|
|
|
|
'LEFT', $this->db->quoteName(
|
|
|
|
'#__componentbuilder_admin_fields_conditions', 'c'
|
|
|
|
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
|
|
|
|
. $this->db->quoteName('c.admin_view') . ')'
|
|
|
|
);
|
|
|
|
|
|
|
|
$query->join(
|
|
|
|
'LEFT', $this->db->quoteName(
|
|
|
|
'#__componentbuilder_admin_fields_relations', 'r'
|
|
|
|
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
|
|
|
|
. $this->db->quoteName('r.admin_view') . ')'
|
|
|
|
);
|
|
|
|
|
|
|
|
$query->join(
|
|
|
|
'LEFT', $this->db->quoteName(
|
|
|
|
'#__componentbuilder_admin_custom_tabs', 't'
|
|
|
|
) . ' ON (' . $this->db->quoteName('a.id') . ' = '
|
|
|
|
. $this->db->quoteName('t.admin_view') . ')'
|
|
|
|
);
|
|
|
|
|
|
|
|
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
|
|
|
|
|
|
|
|
// Trigger Event: jcb_ce_onBeforeQueryViewData
|
|
|
|
$this->event->trigger(
|
2024-01-27 07:09:33 +00:00
|
|
|
'jcb_ce_onBeforeQueryViewData', [&$id, &$query, &$this->db]
|
2023-04-13 15:44:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Reset the query using our newly populated query object.
|
|
|
|
$this->db->setQuery($query);
|
|
|
|
|
|
|
|
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
|
|
|
|
$view = $this->db->loadObject();
|
|
|
|
|
|
|
|
// setup single view code names to use in storing the data
|
|
|
|
$view->name_single_code = 'oops_hmm_' . $id;
|
|
|
|
if (isset($view->name_single) && $view->name_single != 'null')
|
|
|
|
{
|
|
|
|
$view->name_single_code = StringHelper::safe(
|
|
|
|
$view->name_single
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup list view code name to use in storing the data
|
|
|
|
$view->name_list_code = 'oops_hmmm_' . $id;
|
|
|
|
if (isset($view->name_list) && $view->name_list != 'null')
|
|
|
|
{
|
|
|
|
$view->name_list_code = StringHelper::safe(
|
|
|
|
$view->name_list
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the length of the view name (+5 for com_ and _)
|
|
|
|
$name_length = $this->config->component_code_name_length + strlen(
|
|
|
|
(string) $view->name_single_code
|
|
|
|
) + 5;
|
|
|
|
// when the name is larger than 49 we need to add the assets' table name fix
|
|
|
|
if ($name_length > 49)
|
|
|
|
{
|
|
|
|
$this->config->set('add_assets_table_name_fix', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup token check
|
|
|
|
if (!isset($this->dispenser->hub['token']))
|
|
|
|
{
|
|
|
|
$this->dispenser->hub['token'] = [];
|
|
|
|
}
|
|
|
|
$this->dispenser->hub['token'][$view->name_single_code] = false;
|
|
|
|
$this->dispenser->hub['token'][$view->name_list_code] = false;
|
|
|
|
|
|
|
|
// set some placeholders
|
|
|
|
$this->placeholder->set('view', $view->name_single_code);
|
|
|
|
$this->placeholder->set('views', $view->name_list_code);
|
|
|
|
$this->placeholder->set('View', StringHelper::safe(
|
|
|
|
$view->name_single, 'F'
|
|
|
|
));
|
|
|
|
$this->placeholder->set('Views', StringHelper::safe(
|
|
|
|
$view->name_list, 'F'
|
|
|
|
));
|
|
|
|
$this->placeholder->set('VIEW', StringHelper::safe(
|
|
|
|
$view->name_single, 'U'
|
|
|
|
));
|
|
|
|
$this->placeholder->set('VIEWS', StringHelper::safe(
|
|
|
|
$view->name_list, 'U'
|
|
|
|
));
|
|
|
|
|
|
|
|
// Trigger Event: jcb_ce_onBeforeModelViewData
|
|
|
|
$this->event->trigger(
|
2024-01-27 07:09:33 +00:00
|
|
|
'jcb_ce_onBeforeModelViewData', [&$view]
|
2023-04-13 15:44:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// add the tables
|
|
|
|
$view->addtables = (isset($view->addtables)
|
|
|
|
&& JsonHelper::check($view->addtables))
|
|
|
|
? json_decode((string) $view->addtables, true) : null;
|
|
|
|
if (ArrayHelper::check($view->addtables))
|
|
|
|
{
|
|
|
|
$view->tables = array_values($view->addtables);
|
|
|
|
}
|
|
|
|
unset($view->addtables);
|
|
|
|
|
|
|
|
// set custom tabs
|
|
|
|
$this->customtabs->set($view);
|
|
|
|
|
|
|
|
// set the local tabs
|
|
|
|
$this->tabs->set($view);
|
|
|
|
|
|
|
|
// set permissions
|
|
|
|
$this->permissions->set($view);
|
|
|
|
|
|
|
|
// set fields
|
|
|
|
$this->fields->set($view);
|
|
|
|
|
|
|
|
// build update SQL
|
|
|
|
$this->history->set($view);
|
|
|
|
|
|
|
|
// set the conditions
|
|
|
|
$this->conditions->set($view);
|
|
|
|
|
|
|
|
// set the relations
|
|
|
|
$this->relations->set($view);
|
|
|
|
|
|
|
|
// set linked views
|
|
|
|
$this->linkedviews->set($view);
|
|
|
|
|
|
|
|
// set the lang target
|
|
|
|
$this->config->lang_target = 'admin';
|
2023-10-04 18:28:29 +00:00
|
|
|
if ($this->siteeditview->exists($id))
|
2023-04-13 15:44:10 +00:00
|
|
|
{
|
|
|
|
$this->config->lang_target = 'both';
|
|
|
|
}
|
|
|
|
|
|
|
|
// set javascript
|
|
|
|
$this->javascript->set($view);
|
|
|
|
|
|
|
|
// set css
|
|
|
|
$this->css->set($view);
|
|
|
|
|
|
|
|
// set php
|
|
|
|
$this->php->set($view);
|
|
|
|
|
|
|
|
// set custom buttons
|
|
|
|
$this->custombuttons->set($view);
|
|
|
|
|
|
|
|
// set custom import scripts
|
|
|
|
$this->customimportscripts->set($view);
|
|
|
|
|
|
|
|
// set Ajax for this view
|
|
|
|
$this->ajax->set($view);
|
|
|
|
|
|
|
|
// activate alias builder
|
|
|
|
$this->customalias->set($view);
|
|
|
|
|
|
|
|
// set sql
|
|
|
|
$this->sql->set($view);
|
|
|
|
|
|
|
|
// set mySql Table Settings
|
|
|
|
$this->mysqlsettings->set($view);
|
|
|
|
|
|
|
|
// Trigger Event: jcb_ce_onAfterModelViewData
|
|
|
|
$this->event->trigger(
|
2024-01-27 07:09:33 +00:00
|
|
|
'jcb_ce_onAfterModelViewData', [&$view]
|
2023-04-13 15:44:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// clear placeholders
|
|
|
|
$this->placeholder->remove('view');
|
|
|
|
$this->placeholder->remove('views');
|
|
|
|
$this->placeholder->remove('View');
|
|
|
|
$this->placeholder->remove('Views');
|
|
|
|
$this->placeholder->remove('VIEW');
|
|
|
|
$this->placeholder->remove('VIEWS');
|
|
|
|
|
|
|
|
// store this view to class object
|
|
|
|
$this->data[$id] = $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return the found view data
|
|
|
|
return $this->data[$id];
|
2023-10-04 18:28:29 +00:00
|
|
|
}
|