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:
2018-08-23 23:51:09 +02:00
parent fdc66fe4c7
commit 42e85b3944
49 changed files with 334 additions and 100 deletions

View File

@ -103,11 +103,13 @@ class ComponentbuilderModelCompiler extends JModelList
{
// Always create a slug for sef URL's
$item->slug = (isset($item->alias) && isset($item->id)) ? $item->id.':'.$item->alias : $item->id;
// Check if item has params, or pass whole item.
$params = (isset($item->params) && ComponentbuilderHelper::checkJson($item->params)) ? json_decode($item->params) : $item;
// Make sure the content prepare plugins fire on copyright
$_copyright = new stdClass();
$_copyright->text =& $item->copyright; // value must be in text
// Since all values are now in text (Joomla Limitation), we also add the field name (copyright) to context
$this->_dispatcher->trigger("onContentPrepare", array('com_componentbuilder.compiler.copyright', &$_copyright, &$this->params, 0));
$this->_dispatcher->trigger("onContentPrepare", array('com_componentbuilder.compiler.copyright', &$_copyright, &$params, 0));
// Checking if copyright has uikit components that must be loaded.
$this->uikitComp = ComponentbuilderHelper::getUikitComp($item->copyright,$this->uikitComp);
}

View File

@ -86,18 +86,18 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin
$item->metadata = $registry->toArray();
}
if (!empty($item->php_view))
{
// base64 Decode php_view.
$item->php_view = base64_decode($item->php_view);
}
if (!empty($item->php_jview_display))
{
// base64 Decode php_jview_display.
$item->php_jview_display = base64_decode($item->php_jview_display);
}
if (!empty($item->php_view))
{
// base64 Decode php_view.
$item->php_view = base64_decode($item->php_view);
}
if (!empty($item->default))
{
// base64 Decode default.
@ -974,7 +974,32 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin
}
// always reset the snippets
$data['snippet'] = 0;
$data['snippet'] = 0;
// if system name is empty create from name
if (empty($data['system_name']) || !ComponentbuilderHelper::checkString($data['system_name']))
{
$data['system_name'] = $data['name'];
}
// if codename is empty create from name
if (empty($data['codename']) || !ComponentbuilderHelper::checkString($data['codename']))
{
$data['codename'] = ComponentbuilderHelper::safeString($data['name']);
}
else
{
// always make safe string
$data['codename'] = ComponentbuilderHelper::safeString($data['codename']);
}
// if context is empty create from codename
if (empty($data['context']) || !ComponentbuilderHelper::checkString($data['context']))
{
$data['context'] = $data['codename'];
}
else
{
// always make safe string
$data['context'] = ComponentbuilderHelper::safeString($data['context']);
}
// Set the custom_get items to data.
if (isset($data['custom_get']) && is_array($data['custom_get']))
@ -1028,18 +1053,18 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin
$data['custom_button'] = '';
}
// Set the php_view string to base64 string.
if (isset($data['php_view']))
{
$data['php_view'] = base64_encode($data['php_view']);
}
// Set the php_jview_display string to base64 string.
if (isset($data['php_jview_display']))
{
$data['php_jview_display'] = base64_encode($data['php_jview_display']);
}
// Set the php_view string to base64 string.
if (isset($data['php_view']))
{
$data['php_view'] = base64_encode($data['php_view']);
}
// Set the default string to base64 string.
if (isset($data['default']))
{

View File

@ -233,7 +233,7 @@ class ComponentbuilderModelCustom_admin_views extends JModelList
else
{
$search = $db->quote('%' . $db->escape($search) . '%');
$query->where('(a.system_name LIKE '.$search.' OR a.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.main_get LIKE '.$search.' OR g.name LIKE '.$search.' OR a.codename LIKE '.$search.')');
$query->where('(a.system_name LIKE '.$search.' OR a.name LIKE '.$search.' OR a.description LIKE '.$search.' OR a.main_get LIKE '.$search.' OR g.name LIKE '.$search.' OR a.context LIKE '.$search.' OR a.codename LIKE '.$search.')');
}
}
@ -317,10 +317,10 @@ class ComponentbuilderModelCustom_admin_views extends JModelList
continue;
}
// decode php_view
$item->php_view = base64_decode($item->php_view);
// decode php_jview_display
$item->php_jview_display = base64_decode($item->php_jview_display);
// decode php_view
$item->php_view = base64_decode($item->php_view);
// decode default
$item->default = base64_decode($item->default);
// decode php_jview

View File

@ -140,23 +140,6 @@
required="true"
button="true"
/>
<!-- Php_view Field. Type: Editor. (joomla) -->
<field
type="editor"
name="php_view"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_VIEW_LABEL"
description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_VIEW_DESCRIPTION"
width="100%"
height="450px"
cols="15"
rows="30"
buttons="no"
syntax="php"
editor="codemirror|none"
filter="raw"
required="true"
validate="code"
/>
<!-- Php_jview_display Field. Type: Editor. (joomla) -->
<field
type="editor"
@ -174,6 +157,39 @@
required="true"
validate="code"
/>
<!-- Note_add_language_string Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_add_language_string" label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_ADD_LANGUAGE_STRING_LABEL" description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_ADD_LANGUAGE_STRING_DESCRIPTION" heading="h4" class="note_add_language_string" />
<!-- Php_view Field. Type: Editor. (joomla) -->
<field
type="editor"
name="php_view"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_VIEW_LABEL"
description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_VIEW_DESCRIPTION"
width="100%"
height="450px"
cols="15"
rows="30"
buttons="no"
syntax="php"
editor="codemirror|none"
filter="raw"
required="true"
validate="code"
/>
<!-- Add_css_document Field. Type: Radio. (joomla) -->
<field
type="radio"
name="add_css_document"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_CSS_DOCUMENT_LABEL"
class="btn-group btn-group-yesno"
default="0"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_YES</option>
<option value="0">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO</option>
</field>
<!-- Add_css Field. Type: Radio. (joomla) -->
<field
type="radio"
@ -188,8 +204,20 @@
<option value="0">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO</option>
</field>
<!-- Note_add_language_string Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_add_language_string" label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_ADD_LANGUAGE_STRING_LABEL" description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_ADD_LANGUAGE_STRING_DESCRIPTION" heading="h4" class="note_add_language_string" />
<!-- Add_js_document Field. Type: Radio. (joomla) -->
<field
type="radio"
name="add_js_document"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_JS_DOCUMENT_LABEL"
class="btn-group btn-group-yesno"
default="0"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_YES</option>
<option value="0">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO</option>
</field>
<!-- Add_javascript_file Field. Type: Radio. (joomla) -->
<field
type="radio"
@ -205,36 +233,21 @@
<option value="0">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO</option>
</field>
<!-- Add_css_document Field. Type: Radio. (joomla) -->
<field
type="radio"
name="add_css_document"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_CSS_DOCUMENT_LABEL"
class="btn-group btn-group-yesno"
default="0"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_YES</option>
<option value="0">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO</option>
</field>
<!-- Note_libraries_selection Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_libraries_selection" label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_LIBRARIES_SELECTION_LABEL" description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_LIBRARIES_SELECTION_DESCRIPTION" heading="h4" class="alert alert-info note_libraries_selection" />
<!-- Add_js_document Field. Type: Radio. (joomla) -->
<!-- Context Field. Type: Text. (joomla) -->
<field
type="radio"
name="add_js_document"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_ADD_JS_DOCUMENT_LABEL"
class="btn-group btn-group-yesno"
default="0"
required="true">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_YES</option>
<option value="0">
COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO</option>
</field>
type="text"
name="context"
label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CONTEXT_LABEL"
size="40"
maxlength="50"
description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CONTEXT_DESCRIPTION"
class="text_area"
filter="WORD"
message="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CONTEXT_MESSAGE"
hint="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_CONTEXT_HINT"
/>
<!-- Note_snippet_usage Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_snippet_usage" label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_SNIPPET_USAGE_LABEL" heading="h4" class="snippet-usage note_snippet_usage" />
<!-- Default Field. Type: Editor. (joomla) -->

View File

@ -1003,10 +1003,20 @@ class ComponentbuilderModelSite_view extends JModelAdmin
{
$data['codename'] = ComponentbuilderHelper::safeString($data['name']);
}
else
{
// always make safe string
$data['codename'] = ComponentbuilderHelper::safeString($data['codename']);
}
// if context is empty create from codename
if (empty($data['context']) || !ComponentbuilderHelper::checkString($data['context']))
{
$data['context'] = $data['codename'];
}
else
{
// always make safe string
$data['context'] = ComponentbuilderHelper::safeString($data['context']);
}
// Set the custom_get items to data.