Added context to site and custom admin views to better target triggered events. Added the redering option in the admin edit view, so to expand forms via plugins. Improved the codename build in site and custom admin view.
This commit is contained in:
@ -2097,6 +2097,16 @@ class Get
|
||||
$view->code = $this->uniqueCode(ComponentbuilderHelper::safeString($view->codename));
|
||||
$view->Code = ComponentbuilderHelper::safeString($view->code, 'F');
|
||||
$view->CODE = ComponentbuilderHelper::safeString($view->code, 'U');
|
||||
// load context if not set
|
||||
if (!isset($view->context) || !ComponentbuilderHelper::checkString($view->context))
|
||||
{
|
||||
$view->context = $view->code;
|
||||
}
|
||||
else
|
||||
{
|
||||
// always make sure context is a safe string
|
||||
$view->context = ComponentbuilderHelper::safeString($view->context);
|
||||
}
|
||||
// load the library
|
||||
if (!isset($this->libManager[$this->target]))
|
||||
{
|
||||
@ -2168,10 +2178,10 @@ class Get
|
||||
}
|
||||
}
|
||||
// set the main get data
|
||||
$main_get = $this->setGetData(array($view->main_get), $view->code);
|
||||
$main_get = $this->setGetData(array($view->main_get), $view->code, $view->context);
|
||||
$view->main_get = $main_get[0];
|
||||
// set the custom_get data
|
||||
$view->custom_get = $this->setGetData(json_decode($view->custom_get, true), $view->code);
|
||||
$view->custom_get = $this->setGetData(json_decode($view->custom_get, true), $view->code, $view->context);
|
||||
// set array adding array of scripts
|
||||
$addArray = array('php_view', 'php_jview', 'php_jview_display', 'php_document', 'javascript_file', 'js_document', 'css_document', 'css');
|
||||
foreach ($addArray as $scripter)
|
||||
@ -2750,13 +2760,14 @@ class Get
|
||||
/**
|
||||
* Set get Data
|
||||
*
|
||||
* @param array $ids The ids of the dynamic get
|
||||
* @param array $ids The ids of the dynamic get
|
||||
* @param string $view_code The view code name
|
||||
* @param string $context The context for events
|
||||
*
|
||||
* @return oject the get dynamicGet data
|
||||
*
|
||||
*/
|
||||
public function setGetData($ids, $view_code)
|
||||
public function setGetData($ids, $view_code, $context)
|
||||
{
|
||||
if (ComponentbuilderHelper::checkArray($ids))
|
||||
{
|
||||
@ -2828,6 +2839,7 @@ class Get
|
||||
$result->main_get[0]['selection'] = $this->setDataSelection($result->key, $view_code, $result->view_selection, $result->view_table_main, 'a', '', 'view');
|
||||
$result->main_get[0]['as'] = 'a';
|
||||
$result->main_get[0]['key'] = $result->key;
|
||||
$result->main_get[0]['context'] = $context;
|
||||
unset($result->view_selection);
|
||||
break;
|
||||
case 2:
|
||||
@ -2835,6 +2847,7 @@ class Get
|
||||
$result->main_get[0]['selection'] = $this->setDataSelection($result->key, $view_code, $result->db_selection, $result->db_table_main, 'a', '', 'db');
|
||||
$result->main_get[0]['as'] = 'a';
|
||||
$result->main_get[0]['key'] = $result->key;
|
||||
$result->main_get[0]['context'] = $context;
|
||||
unset($result->db_selection);
|
||||
break;
|
||||
case 3:
|
||||
@ -2864,6 +2877,7 @@ class Get
|
||||
$join_field = array_map('trim', explode('.', $option['join_field']));
|
||||
$option['selection'] = $this->setDataSelection($result->key, $view_code, $option['selection'], $option['view_table'], $option['as'], $option['row_type'], 'view');
|
||||
$option['key'] = $result->key;
|
||||
$option['context'] = $context;
|
||||
// load to the getters
|
||||
if ($option['row_type'] == 1)
|
||||
{
|
||||
@ -2910,6 +2924,7 @@ class Get
|
||||
$join_field = array_map('trim', explode('.', $option1['join_field']));
|
||||
$option1['selection'] = $this->setDataSelection($result->key, $view_code, $option1['selection'], $option1['db_table'], $option1['as'], $option1['row_type'], 'db');
|
||||
$option1['key'] = $result->key;
|
||||
$option1['context'] = $context;
|
||||
// load to the getters
|
||||
if ($option1['row_type'] == 1)
|
||||
{
|
||||
|
@ -1809,7 +1809,13 @@ class Interpretation extends Fields
|
||||
{
|
||||
$fieldPrepare = '';
|
||||
$runplugins = false;
|
||||
$context = 'com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '.' . $code;
|
||||
// set component
|
||||
$Component = $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh];
|
||||
// set context
|
||||
$context = (isset($get['context'])) ? $get['context'] : $code;
|
||||
$context = 'com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '.' . $context;
|
||||
// load parms builder only once
|
||||
$params = false;
|
||||
foreach ($checker as $field => $array)
|
||||
{
|
||||
// build load counter
|
||||
@ -1826,11 +1832,17 @@ class Interpretation extends Fields
|
||||
$runplugins .= PHP_EOL . $tab . $this->_t(1) . "JPluginHelper::importPlugin('content');";
|
||||
$runplugins .= PHP_EOL . $tab . $this->_t(1) . '$this->_dispatcher = JEventDispatcher::getInstance();';
|
||||
}
|
||||
if (!$params)
|
||||
{
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " Check if item has params, or pass whole item.";
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "\$params = (isset(" . $string . "->params) && " . $Component . "Helper::checkJson(" . $string . "->params)) ? json_decode(" . $string . "->params) : " . $string . ";";
|
||||
$params = true;
|
||||
}
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " Make sure the content prepare plugins fire on " . $field;
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "\$_" . $field . " = new stdClass();";
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "\$_" . $field . '->text =& ' . $string . '->' . $field . '; //' . $this->setLine(__LINE__) . ' value must be in text';
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " Since all values are now in text (Joomla Limitation), we also add the field name (" . $field . ") to context";
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . '$this->_dispatcher->trigger("onContentPrepare", array(\'' . $context . '.' . $field . '\', &$_' . $field . ', &$this->params, 0));'; // we can improve the params later (TODO)
|
||||
$fieldPrepare .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . '$this->_dispatcher->trigger("onContentPrepare", array(\'' . $context . '.' . $field . '\', &$_' . $field . ', &$params, 0));';
|
||||
}
|
||||
}
|
||||
// load dispatcher
|
||||
@ -3206,6 +3218,8 @@ class Interpretation extends Fields
|
||||
$method .= PHP_EOL . $this->_t(2) . "JPluginHelper::importPlugin('content');";
|
||||
$method .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Setup Event Object.";
|
||||
$method .= PHP_EOL . $this->_t(2) . "\$this->item->event = new stdClass;";
|
||||
$method .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Check if item has params, or pass global params";
|
||||
$method .= PHP_EOL . $this->_t(2) . "\$params = (isset(\$this->item->params) && " . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . "Helper::checkJson(\$this->item->params)) ? json_decode(\$this->item->params) : \$this->params;";
|
||||
// load the defaults
|
||||
foreach ($view['settings']->main_get->plugin_events as $plugin_event)
|
||||
{
|
||||
@ -3219,7 +3233,7 @@ class Interpretation extends Fields
|
||||
else
|
||||
{
|
||||
$method .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " " . $plugin_event . " Event Trigger.";
|
||||
$method .= PHP_EOL . $this->_t(2) . "\$results = \$dispatcher->trigger('" . $plugin_event . "', array('com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . ".article', &\$this->item, &\$this->params, 0));";
|
||||
$method .= PHP_EOL . $this->_t(2) . "\$results = \$dispatcher->trigger('" . $plugin_event . "', array('com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $view['settings']->context . "', &\$this->item, &\$params, 0));";
|
||||
$method .= PHP_EOL . $this->_t(2) . '$this->item->event->' . $plugin_event . ' = trim(implode("\n", $results));';
|
||||
}
|
||||
}
|
||||
@ -7519,13 +7533,10 @@ class Interpretation extends Fields
|
||||
// set counter
|
||||
$tabCounter++;
|
||||
}
|
||||
// add joomla field sets if needed
|
||||
if (isset($view['joomla_fields']) && $view['joomla_fields'] == 1)
|
||||
{
|
||||
$body .= PHP_EOL . PHP_EOL . $this->_t(1) . "<?php \$this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>";
|
||||
$body .= PHP_EOL . $this->_t(1) . "<?php \$this->tab_name = '" . $viewName_single . "Tab'; ?>";
|
||||
$body .= PHP_EOL . $this->_t(1) . "<?php echo JLayoutHelper::render('joomla.edit.params', \$this); ?>";
|
||||
}
|
||||
// add option to load forms loded in via plugins
|
||||
$body .= PHP_EOL . PHP_EOL . $this->_t(1) . "<?php \$this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>";
|
||||
$body .= PHP_EOL . $this->_t(1) . "<?php \$this->tab_name = '" . $viewName_single . "Tab'; ?>";
|
||||
$body .= PHP_EOL . $this->_t(1) . "<?php echo JLayoutHelper::render('joomla.edit.params', \$this); ?>";
|
||||
// set default publishing tab lang
|
||||
$tabLangName = $langView . '_PUBLISHING';
|
||||
// add to lang array
|
||||
@ -7869,7 +7880,7 @@ class Interpretation extends Fields
|
||||
// LAYOUTITEMSTABLE <<<DYNAMIC>>>
|
||||
$this->fileContentDynamic[$viewName_single . '_' . $layoutCodeName][$this->hhh . 'LAYOUTITEMSTABLE' . $this->hhh] = $head . $body;
|
||||
// LAYOUTITEMSHEADER <<<DYNAMIC>>>
|
||||
$headerscript .= '//' . $this->setLine(__LINE__) . ' set the edit URL';
|
||||
$headerscript = '//' . $this->setLine(__LINE__) . ' set the edit URL';
|
||||
$headerscript .= PHP_EOL . '$edit = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $list . '&task=' . $single . '.edit";';
|
||||
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set a return value';
|
||||
$headerscript .= PHP_EOL . '$return = ($id) ? "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $viewName_single . '&layout=edit&id=" . $id : "";';
|
||||
|
Reference in New Issue
Block a user