Added field filtering to admin fields conditions to only load fields linked to admin view. Updated the component export method to also export the new views and field relationships

This commit is contained in:
2017-10-16 19:14:23 +02:00
parent c2972c3e17
commit 6c29a6fca1
320 changed files with 1231 additions and 742 deletions

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 22 of this MVC
@build 13th October, 2017
@build 15th October, 2017
@created 12th October, 2017
@package Component Builder
@subpackage admin_fields.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 15 of this MVC
@build 13th October, 2017
@build 16th October, 2017
@created 12th October, 2017
@package Component Builder
@subpackage admin_fields_conditions.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 185 of this MVC
@build 14th October, 2017
@version @update number 191 of this MVC
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage admin_view.php
@ -465,7 +465,6 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin
{
$this->_db->updateObject('#__componentbuilder_admin_view', $objectUpdate, 'id');
}
// also update the fields and conditions
if (!empty($item->id))
{

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 185 of this MVC
@build 14th October, 2017
@version @update number 191 of this MVC
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage admin_views.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 22 of this MVC
@build 13th October, 2017
@build 15th October, 2017
@created 12th October, 2017
@package Component Builder
@subpackage admins_fields.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 15 of this MVC
@build 13th October, 2017
@build 16th October, 2017
@created 12th October, 2017
@package Component Builder
@subpackage admins_fields_conditions.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage ajax.php
@ -213,6 +213,7 @@ class ComponentbuilderModelAjax extends JModelList
protected $buttonArray = array(
'admin_fields' => 'admins_fields',
'admin_fields_conditions' => 'admins_fields_conditions',
'field' => 'fields',
'language' => true);
public function getButton($type)
@ -346,58 +347,60 @@ class ComponentbuilderModelAjax extends JModelList
'match_behavior' => 'setMatchBehavior',
'match_options' => 'setMatchOptions');
protected function getSubformTable($idName, $oject)
protected function getSubformTable($idName, $data)
{
if (ComponentbuilderHelper::checkJson($oject) && ComponentbuilderHelper::checkString($idName))
// make sure we convert the json to array
if (ComponentbuilderHelper::checkJson($data))
{
$array = json_decode($oject, true);
if (ComponentbuilderHelper::checkArray($array))
{
// Build heading
$head = array();
foreach ($array as $headers)
$data = json_decode($data, true);
}
// make sure we have an array
if (ComponentbuilderHelper::checkArray($data) && ComponentbuilderHelper::checkString($idName))
{
// Build heading
$head = array();
foreach ($data as $headers)
{
foreach ($headers as $header => $value)
{
foreach ($headers as $header => $value)
{
$head[$header] = '<th>' . ComponentbuilderHelper::safeString($header, 'Ww');
}
$head[$header] = '<th>' . ComponentbuilderHelper::safeString($header, 'Ww');
}
// build the rows
$rows = array();
if (ComponentbuilderHelper::checkArray($array) && ComponentbuilderHelper::checkArray($head))
}
// build the rows
$rows = array();
if (ComponentbuilderHelper::checkArray($data) && ComponentbuilderHelper::checkArray($head))
{
foreach ($data as $nr => $values)
{
foreach ($array as $nr => $values)
foreach ($head as $key => $t)
{
foreach ($head as $key => $t)
// set the value for the row
if (isset($values[$key]))
{
// set the value for the row
if (isset($values[$key]))
{
$this->setSubformRows($nr, $this->setSubformValue($key, $values[$key]), $rows);
}
else
{
$this->setSubformRows($nr, $this->setSubformValue($key, ''), $rows);
}
$this->setSubformRows($nr, $this->setSubformValue($key, $values[$key]), $rows);
}
else
{
$this->setSubformRows($nr, $this->setSubformValue($key, ''), $rows);
}
}
}
// build table
if (ComponentbuilderHelper::checkArray($rows) && ComponentbuilderHelper::checkArray($head))
{
// set the number of rows
$this->rowNumber = count($rows);
// return the table
return $this->setSubformTable($head, $rows);
}
}
// build table
if (ComponentbuilderHelper::checkArray($rows) && ComponentbuilderHelper::checkArray($head))
{
// set the number of rows
$this->rowNumber = count($rows);
// return the table
return $this->setSubformTable($head, $rows, $idName);
}
}
return false;
}
protected function setSubformTable($head, $rows)
protected function setSubformTable($head, $rows, $idName)
{
$table[] = "<div class=\"row-fluid\">";
$table[] = "<div class=\"row-fluid\" id=\"vdm_table_display_".$idName."\">";
$table[] = "\t<div class=\"subform-repeatable-wrapper subform-table-layout subform-table-sublayout-section-byfieldsets\">";
$table[] = "\t\t<div class=\"subform-repeatable\">";
$table[] = "\t\t\t<table class=\"adminlist table table-striped table-bordered\">";
@ -469,6 +472,8 @@ class ComponentbuilderModelAjax extends JModelList
// get the field data
if ($fieldsData = ComponentbuilderHelper::getVar($type, (int) $values['a_id'], 'admin_view', $this->fieldsArray[$type]))
{
// check repeatable conversion
$this->checkRepeatableConversion($fieldsData, $type, $values['a_id']);
// get the table
$table = $this->getSubformTable($type, $fieldsData);
// set notice of bad practice
@ -490,6 +495,35 @@ class ComponentbuilderModelAjax extends JModelList
return '<div class="control-group"><div class="alert alert-error"><h4>' . JText::_('COM_COMPONENTBUILDER_TYPE_ERROR') . '</h4><p>' . JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_IF_THIS_CONTINUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR_OF_A_TYPE_ERROR_IN_THE_FIELDS_DISPLAY_REQUEST') . '</p></div></div>';
}
protected $conversionCheck = array(
'addfields' => 'field',
'addconditions' => 'target_field');
protected function checkRepeatableConversion(&$fieldsData, $type, $id)
{
if (ComponentbuilderHelper::checkJson($fieldsData))
{
$fieldsData = json_decode($fieldsData, true);
if (isset($fieldsData[$this->conversionCheck[$this->fieldsArray[$type]]]))
{
$bucket = array();
foreach($fieldsData as $option => $values)
{
foreach($values as $nr => $value)
{
$bucket[$this->fieldsArray[$type].$nr][$option] = $value;
}
}
$fieldsData = json_encode($bucket);
// update the fields
$objectUpdate = new stdClass();
$objectUpdate->admin_view = (int) $id;
$objectUpdate->{$this->fieldsArray[$type]} = $fieldsData;
JFactory::getDbo()->updateObject('#__componentbuilder_'.$type, $objectUpdate, 'admin_view');
}
}
}
protected function setAlignmentName($header, $value)
{
switch ($value)
@ -585,7 +619,7 @@ class ComponentbuilderModelAjax extends JModelList
protected function setTabName($header, $value)
{
if (ComponentbuilderHelper::checkArray($this->tabNames))
if (!ComponentbuilderHelper::checkArray($this->tabNames))
{
// get the view name & id
$values = $this->getViewID();

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage componentbuilder.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage adminviewfolderlist.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage adminviews.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage articles.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage component.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage components.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage customadminviews.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage customfilelist.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage customfolderlist.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage customgets.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage dbtables.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage dynamicget.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage dynamicgets.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage fields.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage fieldtypes.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage ftps.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage lang.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage maingets.php

View File

@ -11,10 +11,10 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage fieldsmulti.php
@subpackage matchfield.php
@author Llewellyn van der Merwe <http://vdm.bz/component-builder>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
@ -31,16 +31,16 @@ jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Fieldsmulti Form Field class for the Componentbuilder component
* Matchfield Form Field class for the Componentbuilder component
*/
class JFormFieldFieldsmulti extends JFormFieldList
class JFormFieldMatchfield extends JFormFieldList
{
/**
* The fieldsmulti field type.
* The matchfield field type.
*
* @var string
*/
public $type = 'fieldsmulti';
public $type = 'matchfield';
/**
* Override to add new button
*
@ -149,23 +149,62 @@ class JFormFieldFieldsmulti extends JFormFieldList
*/
public function getOptions()
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name'),array('id','target_field_name')));
$query->from($db->quoteName('#__componentbuilder_field', 'a'));
$query->where($db->quoteName('a.published') . ' = 1');
$query->order('a.name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '', 'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->target_field_name);
}
}
// load the db opbject
$db = JFactory::getDBO();
// get the input from url
$jinput = JFactory::getApplication()->input;
// get the id
$ID = $jinput->getInt('id', 0);
// rest the fields ids
$fieldIds = array();
if (is_numeric($ID) && $ID >= 1)
{
// get the admin view ID
if ($adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view'))
{
// get all the fields linked to the admin view
if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields'))
{
if (ComponentbuilderHelper::checkJson($addFields))
{
$addFields = json_decode($addFields, true);
if (ComponentbuilderHelper::checkArray($addFields))
{
foreach($addFields as $addField)
{
if (isset($addField['field']))
{
$fieldIds[] = (int) $addField['field'];
}
}
}
}
}
}
}
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name'),array('id','name')));
$query->from($db->quoteName('#__componentbuilder_field', 'a'));
$query->where($db->quoteName('a.published') . ' >= 1');
// filter by fields linked
if (ComponentbuilderHelper::checkArray($fieldIds))
{
// only load these fields
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')');
}
$query->order('a.name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '', 'Select an option');
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->name);
}
}
return $options;
}
}

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage siteviewfolderlist.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage siteviews.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage snippets.php

View File

@ -0,0 +1,209 @@
<?php
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
| |
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage targetfields.php
@author Llewellyn van der Merwe <http://vdm.bz/component-builder>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
Builds Complex Joomla Components
/-----------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Targetfields Form Field class for the Componentbuilder component
*/
class JFormFieldTargetfields extends JFormFieldList
{
/**
* The targetfields field type.
*
* @var string
*/
public $type = 'targetfields';
/**
* Override to add new button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// see if we should add buttons
$setButton = $this->getAttribute('button');
// get html
$html = parent::getInput();
// if true set button
if ($setButton === 'true')
{
$button = array();
$script = array();
$buttonName = $this->getAttribute('name');
// get the input from url
$app = JFactory::getApplication();
$jinput = $app->input;
// get the view name & id
$values = $jinput->getArray(array(
'id' => 'int',
'view' => 'word'
));
// check if new item
$ref = '';
$refJ = '';
if (!is_null($values['id']) && strlen($values['view']))
{
// only load referal if not new item.
$ref = '&amp;ref=' . $values['view'] . '&amp;refid=' . $values['id'];
$refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
}
$user = JFactory::getUser();
// only add if user allowed to create field
if ($user->authorise('field.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build Create button
$buttonNamee = trim($buttonName);
$buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
$buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
$buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
$buttonNamee = ucfirst(strtolower($buttonNamee));
$button[] = '<a id="'.$buttonName.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', $buttonNamee).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
href="index.php?option=com_componentbuilder&amp;view=field&amp;layout=edit'.$ref.'" >
<span class="icon-new icon-white"></span></a>';
}
// only add if user allowed to edit field
if (($buttonName === 'field' || $buttonName === 'fields') && $user->authorise('field.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build edit button
$buttonNamee = trim($buttonName);
$buttonNamee = preg_replace('/_+/', ' ', $buttonNamee);
$buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee);
$buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee);
$buttonNamee = ucfirst(strtolower($buttonNamee));
$button[] = '<a id="'.$buttonName.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('COM_COMPONENTBUILDER_EDIT_S', $buttonNamee).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
<span class="icon-edit"></span></a>';
// build script
$script[] = "
jQuery(document).ready(function() {
jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) {
e.preventDefault();
var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
".$buttonName."Button(".$buttonName."Value);
});
var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val();
".$buttonName."Button(".$buttonName."Value);
});
function ".$buttonName."Button(value) {
if (value > 0) {
// hide the create button
jQuery('#".$buttonName."Create').hide();
// show edit button
jQuery('#".$buttonName."Edit').show();
var url = 'index.php?option=com_componentbuilder&view=fields&task=field.edit&id='+value+'".$refJ."';
jQuery('#".$buttonName."Edit').attr('href', url);
} else {
// show the create button
jQuery('#".$buttonName."Create').show();
// hide edit button
jQuery('#".$buttonName."Edit').hide();
}
}";
}
// check if button was created for field field.
if (is_array($button) && count($button) > 0)
{
// Load the needed script.
$document = JFactory::getDocument();
$document->addScriptDeclaration(implode(' ',$script));
// return the button attached to input field.
return '<div class="input-append">' .$html . implode('',$button).'</div>';
}
}
return $html;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
public function getOptions()
{
// load the db opbject
$db = JFactory::getDBO();
// get the input from url
$jinput = JFactory::getApplication()->input;
// get the id
$ID = $jinput->getInt('id', 0);
// rest the fields ids
$fieldIds = array();
if (is_numeric($ID) && $ID >= 1)
{
// get the admin view ID
if ($adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view'))
{
// get all the fields linked to the admin view
if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields'))
{
if (ComponentbuilderHelper::checkJson($addFields))
{
$addFields = json_decode($addFields, true);
if (ComponentbuilderHelper::checkArray($addFields))
{
foreach($addFields as $addField)
{
if (isset($addField['field']))
{
$fieldIds[] = (int) $addField['field'];
}
}
}
}
}
}
}
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name'),array('id','name')));
$query->from($db->quoteName('#__componentbuilder_field', 'a'));
$query->where($db->quoteName('a.published') . ' >= 1');
// filter by fields linked
if (ComponentbuilderHelper::checkArray($fieldIds))
{
// only load these fields
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')');
}
$query->order('a.name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->name);
}
}
return $options;
}
}

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage viewtabs.php

View File

@ -10,7 +10,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 22 of this MVC
@build 13th October, 2017
@build 15th October, 2017
@created 12th October, 2017
@package Component Builder
@subpackage admin_fields.js

View File

@ -10,7 +10,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 15 of this MVC
@build 13th October, 2017
@build 16th October, 2017
@created 12th October, 2017
@package Component Builder
@subpackage admin_fields_conditions.js

View File

@ -106,9 +106,9 @@
icon="list"
maximum="500">
<form hidden="true" name="list_addconditions_modal" repeat="true">
<!-- Target_field Field. Type: Fieldsmulti. (custom) -->
<!-- Target_field Field. Type: Targetfields. (custom) -->
<field
type="fieldsmulti"
type="targetfields"
name="target_field"
label="COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_TARGET_FIELD_LABEL"
description="COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_TARGET_FIELD_DESCRIPTION"
@ -151,9 +151,9 @@
<option value="1">
COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_CHAIN</option>
</field>
<!-- Match_field Field. Type: Fields. (custom) -->
<!-- Match_field Field. Type: Matchfield. (custom) -->
<field
type="fields"
type="matchfield"
name="match_field"
label="COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_MATCH_FIELD_LABEL"
description="COM_COMPONENTBUILDER_ADMIN_FIELDS_CONDITIONS_MATCH_FIELD_DESCRIPTION"

View File

@ -9,8 +9,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 185 of this MVC
@build 14th October, 2017
@version @update number 191 of this MVC
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage admin_view.js
@ -1187,6 +1187,8 @@ jQuery(document).ready(function()
getFieldsDisplay('admin_fields_conditions');
// set button
addButtonID('admin_fields_conditions','create_edit_buttons', 1); // <-- second
// set button to add more languages
addButton('field','create_edit_buttons'); // <-- third
});
function getFieldsDisplay(type){
@ -1241,6 +1243,27 @@ function addButtonID(type, where, size){
}
});
}
function addButton_server(type){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getButton&format=json&vdm="+vastDevMod);
if(token.length > 0 && type.length > 0){
var request = 'token='+token+'&type='+type;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function addButton(type,where){
addButton_server(type).done(function(result) {
if(result){
addData(result,'#jform_'+where);
}
})
}
function getTableColumns_server(tableName){
var getUrl = "index.php?option=com_componentbuilder&task=ajax.tableColumns&format=json";

View File

@ -9,8 +9,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 389 of this MVC
@build 14th October, 2017
@version @update number 412 of this MVC
@build 16th October, 2017
@created 6th May, 2015
@package Component Builder
@subpackage joomla_component.js

View File

@ -9,8 +9,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 44 of this MVC
@build 12th October, 2017
@version @update number 45 of this MVC
@build 14th October, 2017
@created 3rd April, 2017
@package Component Builder
@subpackage language_translation.js
@ -29,6 +29,10 @@ jQuery(document).ready(function($)
// set button to add more languages
addButton('language','components');
});
function addData(result,where){
jQuery(where).closest('.control-group').parent().append(result);
}
function addButton_server(type){
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getButton&format=json&vdm="+vastDevMod);
if(token.length > 0 && type.length > 0){
@ -42,13 +46,10 @@ function addButton_server(type){
jsonp: 'callback'
});
}
function addButton(type, where){
function addButton(type,where){
addButton_server(type).done(function(result) {
if(result){
setButton(result, '#jform_'+where);
addData(result,'#jform_'+where);
}
});
}
function setButton(result, where){
jQuery(where).closest('.control-group').append(result);
}
})
}

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage import.php

View File

@ -11,7 +11,7 @@
/-------------------------------------------------------------------------------------------------------------------------------/
@version 2.5.8
@build 14th October, 2017
@build 16th October, 2017
@created 30th April, 2015
@package Component Builder
@subpackage import_joomla_components.php
@ -654,6 +654,16 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
{
return false;
}
// we then store the admin_fields
if (!$this->saveSmartItems($data, 'admin_fields'))
{
return false;
}
// we then store the admin_fields_conditions
if (!$this->saveSmartItems($data, 'admin_fields_conditions'))
{
return false;
}
// we then store the snippet
if (!$this->saveSmartItems($data, 'snippet'))
{
@ -1013,7 +1023,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
}
/*
* Convert repeatable field
* Convert repeatable field to subform
*
* @param array $array The array
* @param string $name The main field name
@ -1154,11 +1164,11 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
if (isset($updateArray[$sleutel]))
{
$updateArray = $this->convertRepeatable($updateArray, $up);
// load it back
$item->{$up} = json_encode($updateArray);
}
// load it back
$item->{$up} = json_encode($updateArray);
}
else
elseif (isset($item->{$up}))
{
unset($item->{$up});
}
@ -1275,6 +1285,30 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// $this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSNIPPETB_IDS_MISMATCH_IN_BSB', $item->snippet, ComponentbuilderHelper::safeString($type, 'w').':'.$item->id), 'warning');
// unset($item->snippet);
}
// repeatable fields to update
$updaterR = array(
'ajax_input' => 'value_name',
'custom_button' => 'name'
);
// update the repeatable fields
foreach ($updaterR as $up => $sleutel)
{
if (isset($item->{$up}) && ComponentbuilderHelper::checkJson($item->{$up}))
{
$updateArray = json_decode($item->{$up}, true);
// check if this is old values for repeatable fields
if (isset($updateArray[$sleutel]))
{
$updateArray = $this->convertRepeatable($updateArray, $up);
// load it back
$item->{$up} = json_encode($updateArray);
}
}
elseif (isset($item->{$up}))
{
unset($item->{$up});
}
}
break;
case 'admin_view':
// we must clear the demo content (since it was not moved as far as we know) TODO
@ -1285,29 +1319,17 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
unset($item->source);
unset($item->addtables);
}
// update the addfields
// update the addfields (old dataset)
if (isset($item->addfields) && ComponentbuilderHelper::checkJson($item->addfields))
{
$addfields = json_decode($item->addfields, true);
foreach ($addfields['field'] as $nr => $id)
{
if (!is_numeric($id))
{
continue;
}
// update the addfields
if (isset($this->newID['field'][$id]))
{
$addfields['field'][$nr] = $this->newID['field'][$id];
}
else
{
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BFIELD_IN_SB_HAS_ID_MISMATCH_OF_SELECTED_BFIELDB_SO_THE_IDS_WAS_REMOVED', '('.ComponentbuilderHelper::safeString($type, 'w').':'.$item->id.')', $id), 'warning');
$addfields['field'][$nr] = '';
}
}
// load it back
$item->addfields = json_encode($addfields);
// set the targets
$targets = array('field' => 'field');
// set the anchors
$anchor = array('admin_view' => $item->id);
// move the old data
$this->moveData($item->addfields, 'admin_fields', 'addfields', 'target_field', $targets, $anchor);
// remove from this dataset
unset($item->addfields);
}
else
{
@ -1322,55 +1344,50 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
{
unset($item->addlinked_views);
}
// update the addconditions
if (isset($item->addconditions) && ComponentbuilderHelper::checkJson($item->addconditions))
// update the addconditions (old dataset)
if (isset($item->addconditions))
{
$addconditions = json_decode($item->addconditions, true);
$targets = array('target_field', 'match_field');
foreach ($targets as $target)
{
foreach ($addconditions[$target] as $nr => $ids)
{
// update the addconditions
if (!ComponentbuilderHelper::checkArray($ids))
{
$ids = array((int) $ids);
}
// the bucket to load the items back
$bucket = array();
foreach ($ids as $id)
{
if (!is_numeric($id))
{
continue;
}
if (isset($this->newID['field'][$id]))
{
$bucket[] = $this->newID['field'][$id];
}
else
{
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSB_HAS_ID_MISMATCH_OF_SELECTED_BFIELDB_SO_THE_IDS_WAS_REMOVED', ComponentbuilderHelper::safeString($target, 'Ww') . ' in ('.ComponentbuilderHelper::safeString($type, 'w').':'.$item->id.')', $id), 'warning');
$bucket[] = '';
}
}
if (count($bucket) == 1)
{
$addconditions[$target][$nr] = $bucket[0];
}
elseif (count($bucket) > 1)
{
$addconditions[$target][$nr] = $bucket;
}
}
}
// load it back
$item->addconditions = json_encode($addconditions);
// set the targets
$targets = array('target_field' => 'field', 'match_field' => 'field');
// set the anchors
$anchor = array('admin_view' => $item->id);
// move the old data
$this->moveData($item->addconditions, 'admin_fields_conditions', 'addconditions', 'target_field', $targets, $anchor);
// remove from this dataset
unset($item->addconditions);
}
else
{
unset($item->addconditions);
}
// repeatable fields to update
$updaterR = array(
'ajax_input' => 'value_name',
'custom_button' => 'name',
'addtables' => 'table',
'addlinked_views' => 'adminview',
'addtabs' => 'name',
'addpermissions' => 'action'
);
// update the repeatable fields
foreach ($updaterR as $up => $sleutel)
{
if (isset($item->{$up}) && ComponentbuilderHelper::checkJson($item->{$up}))
{
$updateArray = json_decode($item->{$up}, true);
// check if this is old values for repeatable fields
if (isset($updateArray[$sleutel]))
{
$updateArray = $this->convertRepeatable($updateArray, $up);
// load it back
$item->{$up} = json_encode($updateArray);
}
}
elseif (isset($item->{$up}))
{
unset($item->{$up});
}
}
break;
case 'joomla_component':
// update the addconfig
@ -1645,8 +1662,6 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
return false;
}
/**
* Check if a field has multiple fields
*
@ -1676,6 +1691,116 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
return false;
}
/**
* Move old repeatable field to new subform field, and new table
*
* @param array/json $values The values to move
* @param string $table The table to move the values to
* @param string $type The type of values
* @param string $checker The key to check if this is a repeatable field
* @param array $targets The target to update and its type
* @param array $anchor The fields to use in anchoring to the new table
*
* @return void
*/
protected function moveData($values, $table, $type, $checker, $targets, $anchor)
{
if (ComponentbuilderHelper::checkJson($values))
{
$values = json_decode($values, true);
}
// check if this is old values for repeatable fields
if (ComponentbuilderHelper::checkArray($values) && isset($values[$checker]))
{
$values = $this->convertRepeatable($values, $type);
}
// now update the fields
if (ComponentbuilderHelper::checkArray($values))
{
foreach ($values as $nr => &$value)
{
foreach ($targets as $target => $target_type)
{
if (isset($value[$target]))
{
// update the target
if (!ComponentbuilderHelper::checkArray($value[$target]))
{
if (isset($this->newID[$target_type][$value[$target]]))
{
$value[$target] = $this->newID[$target_type][$value[$target]];
}
else
{
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSB_HAS_ID_MISMATCH_SO_THE_IDS_WAS_REMOVED', ComponentbuilderHelper::safeString($target_type, 'Ww') . '->' . ComponentbuilderHelper::safeString($target, 'Ww') .' in ('.ComponentbuilderHelper::safeString($table, 'w').':'.$item->id.')', $value[$target]), 'warning');
$value[$target] = '';
}
}
elseif (ComponentbuilderHelper::checkArray($value[$target]))
{
// the bucket to load the items back
$bucket = array();
foreach ($value[$target] as $id)
{
if (!is_numeric($id))
{
continue;
}
if (isset($this->newID[$target_type][$id]))
{
$bucket[] = $this->newID[$target_type][$id];
}
else
{
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BSB_HAS_ID_MISMATCH_SO_THE_IDS_WAS_REMOVED', ComponentbuilderHelper::safeString($target_type, 'Ww') . '->' . ComponentbuilderHelper::safeString($target, 'Ww') .' in ('.ComponentbuilderHelper::safeString($table, 'w').':'.$item->id.')', $id), 'warning');
$bucket[] = '';
}
}
// set ids back
if (ComponentbuilderHelper::checkArray($bucket))
{
$value[$target] = $bucket;
}
}
}
}
}
}
// we need to move this to the new $table based on anchors
if (ComponentbuilderHelper::checkArray($anchor))
{
$anchorArray = array();
foreach ($anchor as $name => $id)
{
$updated = false;
if (isset($this->newID[$name]) && isset($this->newID[$name][$id]))
{
$id = $this->newID[$name][$id];
$updated = true;
}
// set the values
$anchorArray[$name] = array('value' => $id, 'updated' => $updated);
}
if (!isset($this->dataMover[$table]))
{
$this->dataMover[$table] = array();
}
// set unique key
$uniqueKey = md5(serialize($anchorArray));
if (!isset($this->dataMover[$table][$uniqueKey]))
{
$this->dataMover[$table][$uniqueKey] = array();
$this->dataMover[$table][$uniqueKey]['<(--AnCh0r'] = $anchorArray;
}
// add the data to the mover
$this->dataMover[$table][$uniqueKey][$type] = json_encode($values);
}
else
{
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_WE_FAILED_TO_MOVE_BSB', ComponentbuilderHelper::safeString($type, 'Ww') . ' to ('.ComponentbuilderHelper::safeString($table, 'w').')'), 'warning');
}
}
/**
* Get the field type
*
@ -1727,9 +1852,9 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
/**
* Update the local item
*
* @param object $item The item to update
* @param string $type The type of values
* @param bool $canState The switch to set state
* @param object $item The item to update
* @param string $type The type of values
* @param bool $canState The switch to set state
*
* @return mixed false on failure
* ID int on success
@ -1894,6 +2019,16 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// set the getter
switch ($type)
{
case 'admin_fields':
case 'admin_fields_conditions':
// get by admin_view (since there should only be one of each name)
$getter = 'admin_view';
// update the admin_view with the local ID
if (isset($this->newID[$getter]) && isset($this->newID[$getter][$item->admin_view]))
{
$item->{$getter} = (int) $this->newID[$getter][$item->{$getter}];
}
break;
case 'fieldtype':
// get by name (since there should only be one of each name)
$getter = 'name';

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 389 of this MVC
@build 14th October, 2017
@version @update number 412 of this MVC
@build 16th October, 2017
@created 6th May, 2015
@package Component Builder
@subpackage joomla_component.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 389 of this MVC
@build 14th October, 2017
@version @update number 412 of this MVC
@build 16th October, 2017
@created 6th May, 2015
@package Component Builder
@subpackage joomla_components.php
@ -82,6 +82,10 @@ class ComponentbuilderModelJoomla_components extends JModelList
protected $customPath;
protected $smartExport = array();
protected $templateIds = array();
protected $dynamicGetIds = array();
protected $adminViewIds = array();
protected $fieldTypeIds = array();
protected $snippetIds = array();
protected $layoutIds = array();
protected $customCodeIds = array();
protected $customCodeM = array();
@ -261,13 +265,13 @@ class ComponentbuilderModelJoomla_components extends JModelList
// component image
$this->moveIt(array('image' => array($item->image)), 'image');
// add config fields
$this->setData('field', $item->addconfig, 'field');
$this->setData('field', $this->getIds($item->addconfig, 'repeatable', 'field'), 'id');
// add admin views
$this->setData('admin_view', $item->addadmin_views, 'adminview');
$this->setData('admin_view', $this->getIds($item->addadmin_views, 'repeatable', 'adminview'), 'id');
// add custom admin views
$this->setData('custom_admin_view', $item->addcustom_admin_views, 'customadminview');
$this->setData('custom_admin_view', $this->getIds($item->addcustom_admin_views, 'repeatable', 'customadminview'), 'id');
// add site views
$this->setData('site_view', $item->addsite_views, 'siteview');
$this->setData('site_view', $this->getIds($item->addsite_views, 'repeatable', 'siteview'), 'id');
// set the custom code ID's
$this->setCustomCodeIds($item, 'joomla_component');
// set the language strings for this component
@ -275,20 +279,41 @@ class ComponentbuilderModelJoomla_components extends JModelList
// load to global object
$this->smartExport['joomla_component'][$item->id] = $item;
}
// add fields and conditions
if (ComponentbuilderHelper::checkArray($this->adminViewIds))
{
$this->setData('admin_fields', $this->adminViewIds, 'id');
$this->setData('admin_fields_conditions', $this->adminViewIds, 'id');
}
// add field types
if (ComponentbuilderHelper::checkArray($this->fieldTypeIds))
{
$this->setData('fieldtype', $this->fieldTypeIds, 'id');
}
// add dynamic get
if (ComponentbuilderHelper::checkArray($this->dynamicGetIds))
{
$this->setData('dynamic_get', $this->dynamicGetIds, 'id');
}
// add snippets
if (ComponentbuilderHelper::checkArray($this->snippetIds))
{
$this->setData('snippet', $this->snippetIds, 'id');
}
// add templates
if (ComponentbuilderHelper::checkArray($this->templateIds))
{
$this->setData('template', array('template' => $this->templateIds), 'template');
$this->setData('template', $this->templateIds, 'id');
}
// add layouts
if (ComponentbuilderHelper::checkArray($this->layoutIds))
{
$this->setData('layout', array('layout' => $this->layoutIds), 'layout');
$this->setData('layout', $this->layoutIds, 'id');
}
// add custom code
if (ComponentbuilderHelper::checkArray($this->customCodeIds))
{
$this->setData('custom_code', array('custom_code' => $this->customCodeIds), 'custom_code');
$this->setData('custom_code', $this->customCodeIds, 'id');
}
// has any data been set
if (ComponentbuilderHelper::checkArray($this->smartExport['joomla_component']))
@ -302,6 +327,237 @@ class ComponentbuilderModelJoomla_components extends JModelList
return false;
}
/**
* Method to get ids.
*
* @return mixed An array of ids on success, false on failure.
*/
protected function getIds($values, $type, $key = null)
{
// the ids bucket
$bucket = array();
// if json convert to array
if (ComponentbuilderHelper::checkJson($values))
{
$values = json_decode($values, true);
}
// check that the array has values
if (ComponentbuilderHelper::checkArray($values))
{
// check if the key is an array (targeting subform)
if ('subform' === $type && $key)
{
foreach ($values as $value)
{
if (isset($value[$key]))
{
if (is_numeric($value[$key]))
{
$bucket[] = $value[$key];
}
elseif (ComponentbuilderHelper::checkString($value[$key]))
{
$bucket[] = $this->_db->quote($value[$key]);
}
}
}
// only return if we set the ids
if (ComponentbuilderHelper::checkArray($bucket))
{
// now set the values back
return array_unique($bucket);
}
}
// check if the key is an array (targeting subform)
if ('repeatable' === $type && $key)
{
if (isset($values[$key]))
{
return array_map(function($id) {
if (is_numeric($id))
{
return $id;
}
elseif (ComponentbuilderHelper::checkString($id))
{
return $this->_db->quote($id);
}
}, array_unique($values[$key]) );
}
}
}
return false;
}
/**
* Method to get data of a given table.
*
* @return mixed An array of data items on success, false on failure.
*/
protected function setData($table, $values, $key)
{
// make sure we have an array of values
if (!ComponentbuilderHelper::checkArray($values) || !ComponentbuilderHelper::checkString($table) || !ComponentbuilderHelper::checkString($key))
{
return false;
}
// start the query
$query = $this->_db->getQuery(true);
// Select some fields
$query->select(array('a.*'));
// From the componentbuilder_ANY table
$query->from($this->_db->quoteName('#__componentbuilder_'. $table, 'a'));
// set the where query
$query->where('a.'.$key.' IN (' . implode(',',$values) . ')');
// Implement View Level Access
if (!$this->user->authorise('core.options', 'com_componentbuilder'))
{
$groups = implode(',', $this->user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$this->_db->setQuery($query);
$this->_db->execute();
if ($this->_db->getNumRows())
{
$items = $this->_db->loadObjectList();
// check if we have items
if (ComponentbuilderHelper::checkArray($items))
{
// set search array
if ('site_view' === $table || 'custom_admin_view' === $table)
{
$searchArray = array('php_view','php_jview','php_jview_display','php_document','js_document','css_document','css');
}
// reset the global array
if ('template' === $table)
{
$this->templateIds = array();
}
elseif ('layout' === $table)
{
$this->layoutIds = array();
}
// start loading the data
if (!isset($this->smartExport[$table]))
{
$this->smartExport[$table] = array();
}
// start loading the found items
foreach ($items as $nr => &$item)
{
// set the data per id only once
if (isset($this->smartExport[$table][$item->id]))
{
continue;
}
// load to global object
$this->smartExport[$table][$item->id] = $item;
// set the custom code ID's
$this->setCustomCodeIds($item, $table);
// actions to take if table is admin_view
if ('admin_view' === $table)
{
// add fields & conditions
$this->adminViewIds[$item->id] = $item->id;
// admin icon
$this->moveIt(array('image' => array($item->icon)), 'image');
// admin icon_add
$this->moveIt(array('image' => array($item->icon_add)), 'image');
// admin icon_category
$this->moveIt(array('image' => array($item->icon_category)), 'image');
}
// actions to take if table is admin_fields
if ('admin_fields' === $table)
{
// add fields
$this->setData('field', $this->getIds($item->addfields, 'subform', 'field'), 'id');
}
// actions to take if table is field
if ('field' === $table)
{
// add field types
$this->fieldTypeIds[$item->fieldtype] = $item->fieldtype;
// check if this field has multiple fields
if ($this->checkMultiFields($item->fieldtype))
{
$fields = ComponentbuilderHelper::getBetween(json_decode($item->xml), 'fields="', '"');
$fieldsSets = array();
if (strpos($fields, ',') !== false)
{
// multiple fields
$fieldsSets = (array) explode(',', $fields);
}
elseif (is_numeric($fields))
{
// single field
$fieldsSets[] = (int) $fields;
}
// get fields
if (ComponentbuilderHelper::checkArray($fieldsSets))
{
$this->setData('field', $fieldsSets, 'id');
}
}
}
// actions to take if table is site_view and custom_admin_view
if ('site_view' === $table || 'custom_admin_view' === $table)
{
// search for templates & layouts
$this->getTemplateLayout(base64_decode($item->default));
// add search array templates and layouts
foreach ($searchArray as $scripter)
{
if (isset($item->{'add_'.$scripter}) && $item->{'add_'.$scripter} == 1)
{
$this->getTemplateLayout($item->$scripter);
}
}
// add dynamic gets
$this->dynamicGetIds[$item->main_get] = $item->main_get;
if (ComponentbuilderHelper::checkArray($item->custom_get))
{
foreach ($item->custom_get as $custom_get)
{
// add dynamic gets
$this->dynamicGetIds[$custom_get] = $custom_get;
}
}
if ('custom_admin_view' === $table && isset($item->icon))
{
// view icon
$this->moveIt(array('image' => array($item->icon)), 'image');
}
// add snippets
$this->snippetIds[$item->snippet] = $item->snippet;
}
// actions to take if table is template and layout
if ('layout' === $table || 'template' === $table)
{
// search for templates & layouts
$this->getTemplateLayout(base64_decode($item->$table), $this->user);
// add search array templates and layouts
if (isset($item->add_php_view) && $item->add_php_view == 1)
{
$this->getTemplateLayout($item->php_view, $this->user);
}
// add dynamic gets
$this->dynamicGetIds[$item->dynamic_get] = $item->dynamic_get;
// add snippets
$this->snippetIds[$item->snippet] = $item->snippet;
}
}
}
}
}
/**
* Method to build the package to export
*
@ -518,213 +774,6 @@ class ComponentbuilderModelJoomla_components extends JModelList
return true;
}
/**
* Method to get data of a given table.
*
* @return mixed An array of data items on success, false on failure.
*/
protected function setData($table, $values, $key)
{
// if json convert to array
if (ComponentbuilderHelper::checkJson($values))
{
$values = json_decode($values, true);
}
// check if the key is an array (targeting subform)
if (ComponentbuilderHelper::checkArray($key) && isset($key['subform']) && ComponentbuilderHelper::checkArray($values))
{
$subform = $key['subform'];
$key = $key['key'];
$tmpBucket = array($key => array());
foreach ($values as $value)
{
if (isset($value[$subform]))
{
if ('language' === $subform)
{
$tmpBucket[$key][] = (int) ComponentbuilderHelper::getVar('language', $value[$subform], 'langtag', 'id');
}
else
{
$tmpBucket[$key][] = $value[$subform];
}
}
}
if (ComponentbuilderHelper::checkArray($tmpBucket[$key]))
{
// now set the values back
$values = $tmpBucket;
}
else
{
return false;
}
}
elseif (ComponentbuilderHelper::checkArray($key))
{
return false;
}
// make sure we have an array
if (('custom_code' !== $table && 'component' !== $key && 'custom_get' !== $key) && (!ComponentbuilderHelper::checkArray($values) || !isset($values[$key]) || !ComponentbuilderHelper::checkArray($values[$key])))
{
return false;
}
elseif (!ComponentbuilderHelper::checkArray($values))
{
return false;
}
$query = $this->_db->getQuery(true);
// Select some fields
$query->select(array('a.*'));
// From the componentbuilder_ANY table
$query->from($this->_db->quoteName('#__componentbuilder_'. $table, 'a'));
if ('custom_code' === $table && 'component' === $key)
{
$query->where('a.component IN (' . implode(',',$values) . ')');
}
elseif ('custom_get' === $key)
{
$query->where('a.id IN (' . implode(',',$values) . ')');
}
else
{
$query->where('a.id IN (' . implode(',',$values[$key]) . ')');
}
// Implement View Level Access
if (!$this->user->authorise('core.options', 'com_componentbuilder'))
{
$groups = implode(',', $this->user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$this->_db->setQuery($query);
$this->_db->execute();
if ($this->_db->getNumRows())
{
$items = $this->_db->loadObjectList();
// check if we have items
if (ComponentbuilderHelper::checkArray($items))
{
// set search array
if ('site_view' === $table || 'custom_admin_view' === $table)
{
$searchArray = array('php_view','php_jview','php_jview_display','php_document','js_document','css_document','css');
}
// reset the global array
if ('template' === $table)
{
$this->templateIds = array();
}
elseif ('layout' === $table)
{
$this->layoutIds = array();
}
// start loading the data
if (!isset($this->smartExport[$table]))
{
$this->smartExport[$table] = array();
}
foreach ($items as $nr => &$item)
{
// set the data per id only once
if (isset($this->smartExport[$table][$item->id]))
{
continue;
}
// load to global object
$this->smartExport[$table][$item->id] = $item;
// set the custom code ID's
$this->setCustomCodeIds($item, $table);
// actions to take if table is admin_view
if ('admin_view' === $table)
{
// add fields
$this->setData('field', $item->addfields, 'field');
// admin icon
$this->moveIt(array('image' => array($item->icon)), 'image');
// admin icon_add
$this->moveIt(array('image' => array($item->icon_add)), 'image');
// admin icon_category
$this->moveIt(array('image' => array($item->icon_category)), 'image');
}
// actions to take if table is field
if ('field' === $table)
{
// add field types
$this->setData('fieldtype', array('fieldtype' => array($item->fieldtype)), 'fieldtype');
// check if this field has multiple fields
if ($this->checkMultiFields($item->fieldtype))
{
$fields = ComponentbuilderHelper::getBetween(json_decode($item->xml), 'fields="', '"');
$fieldsSets = array();
if (strpos($fields, ',') !== false)
{
// multiple fields
$fieldsSets = (array) explode(',', $fields);
}
elseif (is_numeric($fields))
{
// single field
$fieldsSets[] = (int) $fields;
}
// get fields
if (ComponentbuilderHelper::checkArray($fieldsSets))
{
$this->setData('field', array('field' => $fieldsSets), 'field');
}
}
}
// actions to take if table is site_view and custom_admin_view
if ('site_view' === $table || 'custom_admin_view' === $table)
{
// search for templates & layouts
$this->getTemplateLayout(base64_decode($item->default));
// add search array templates and layouts
foreach ($searchArray as $scripter)
{
if (isset($item->{'add_'.$scripter}) && $item->{'add_'.$scripter} == 1)
{
$this->getTemplateLayout($item->$scripter);
}
}
// add dynamic gets
$this->setData('dynamic_get', array('dynamic_get' => array($item->main_get)), 'dynamic_get');
$this->setData('dynamic_get', $item->custom_get, 'custom_get');
if ('custom_admin_view' === $table && isset($item->icon))
{
// view icon
$this->moveIt(array('image' => array($item->icon)), 'image');
}
// add snippets
$this->setData('snippet', array('snippet' => array($item->snippet)), 'snippet');
}
// actions to take if table is template and layout
if ('layout' === $table || 'template' === $table)
{
// search for templates & layouts
$this->getTemplateLayout(base64_decode($item->$table), $this->user);
// add search array templates and layouts
if (isset($item->add_php_view) && $item->add_php_view == 1)
{
$this->getTemplateLayout($item->php_view, $this->user);
}
// add dynamic gets
$this->setData('dynamic_get', array('dynamic_get' => $item->dynamic_get), 'dynamic_get');
// add snippets
$this->setData('snippet', array('snippet' => array($item->snippet)), 'snippet');
}
}
}
}
}
/**
* Check if a field has multiple fields
*
@ -891,12 +940,12 @@ class ComponentbuilderModelJoomla_components extends JModelList
// add templates
if (ComponentbuilderHelper::checkArray($this->templateIds))
{
$this->setData('template', array('template' => $this->templateIds), 'template');
$this->setData('template', $this->templateIds, 'id');
}
// add layouts
if (ComponentbuilderHelper::checkArray($this->layoutIds))
{
$this->setData('layout', array('layout' => $this->layoutIds), 'layout');
$this->setData('layout', $this->layoutIds, 'id');
}
}
}
@ -1045,7 +1094,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
// add languages
if (isset($item->translation))
{
$this->setData('language', $item->translation, array('key' => 'language', 'subform' => 'language'));
$this->setData('language', $this->getIds($item->translation, 'subform', 'language'), 'langtag');
}
}
}

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 44 of this MVC
@build 12th October, 2017
@version @update number 45 of this MVC
@build 14th October, 2017
@created 3rd April, 2017
@package Component Builder
@subpackage language_translation.php

View File

@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@version @update number 44 of this MVC
@build 12th October, 2017
@version @update number 45 of this MVC
@build 14th October, 2017
@created 3rd April, 2017
@package Component Builder
@subpackage language_translations.php