Resolves gh-63 to prevent repeateble field from being created a second time. Resolves gh-62 to insure full encryption of JCB packages.
This commit is contained in:
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage ajax.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage componentbuilder.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage adminviewfolderlist.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage adminviews.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage articles.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage component.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage customadminviews.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage customfilelist.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage customfolderlist.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage customgets.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage dbtables.php
|
||||
|
173
admin/models/fields/dynamicget.php
Normal file
173
admin/models/fields/dynamicget.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
||||
__ __ _ _____ _ _ __ __ _ _ _
|
||||
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
||||
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
||||
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
||||
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
||||
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
||||
| |
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage dynamicget.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');
|
||||
|
||||
/**
|
||||
* Dynamicget Form Field class for the Componentbuilder component
|
||||
*/
|
||||
class JFormFieldDynamicget extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The dynamicget field type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'dynamicget';
|
||||
/**
|
||||
* 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 = '&ref=' . $values['view'] . '&refid=' . $values['id'];
|
||||
$refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
|
||||
}
|
||||
$user = JFactory::getUser();
|
||||
// only add if user allowed to create dynamic_get
|
||||
if ($user->authorise('dynamic_get.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&view=dynamic_get&layout=edit'.$ref.'" >
|
||||
<span class="icon-new icon-white"></span></a>';
|
||||
}
|
||||
// only add if user allowed to edit dynamic_get
|
||||
if (($buttonName === 'dynamic_get' || $buttonName === 'dynamic_gets') && $user->authorise('dynamic_get.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=dynamic_gets&task=dynamic_get.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 dynamic_get 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()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.id','a.name','a.gettype'),array('id','dynamic_get_name','type')));
|
||||
$query->from($db->quoteName('#__componentbuilder_dynamic_get', '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');
|
||||
$model = ComponentbuilderHelper::getModel('dynamic_gets');
|
||||
foreach($items as $item)
|
||||
{
|
||||
$type = $model->selectionTranslation($item->type,'gettype');
|
||||
$options[] = JHtml::_('select.option', $item->id, $item->dynamic_get_name . ' (' . JText::_($type) . ')' );
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
}
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage dynamicgets.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage fields.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage fieldsmulti.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage fieldtypes.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage maingets.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage siteviewfolderlist.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage siteviews.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage snippets.php
|
||||
|
@ -9,8 +9,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 297 of this MVC
|
||||
@build 31st March, 2017
|
||||
@version @update number 311 of this MVC
|
||||
@build 1st April, 2017
|
||||
@created 6th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage joomla_component.js
|
||||
|
@ -10,7 +10,7 @@
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 67 of this MVC
|
||||
@build 22nd February, 2017
|
||||
@build 1st April, 2017
|
||||
@created 18th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage layout.js
|
||||
|
@ -135,14 +135,14 @@
|
||||
message="Error! Please add description here."
|
||||
hint="COM_COMPONENTBUILDER_LAYOUT_DESCRIPTION_HINT"
|
||||
/>
|
||||
<!-- Dynamic_get Field. Type: Dynamicgets. (custom) -->
|
||||
<!-- Dynamic_get Field. Type: Dynamicget. (custom) -->
|
||||
<field
|
||||
type="dynamicgets"
|
||||
type="dynamicget"
|
||||
name="dynamic_get"
|
||||
label="COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_LABEL"
|
||||
description="COM_COMPONENTBUILDER_LAYOUT_DYNAMIC_GET_DESCRIPTION"
|
||||
multiple="false"
|
||||
required="true"
|
||||
required="false"
|
||||
button="true"
|
||||
/>
|
||||
<!-- Snippet Field. Type: Snippets. (custom) -->
|
||||
|
@ -10,7 +10,7 @@
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 40 of this MVC
|
||||
@build 22nd February, 2017
|
||||
@build 1st April, 2017
|
||||
@created 26th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage template.js
|
||||
|
@ -192,14 +192,14 @@
|
||||
<option value="0">
|
||||
COM_COMPONENTBUILDER_TEMPLATE_NO</option>
|
||||
</field>
|
||||
<!-- Dynamic_get Field. Type: Dynamicgets. (custom) -->
|
||||
<!-- Dynamic_get Field. Type: Dynamicget. (custom) -->
|
||||
<field
|
||||
type="dynamicgets"
|
||||
type="dynamicget"
|
||||
name="dynamic_get"
|
||||
label="COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_LABEL"
|
||||
description="COM_COMPONENTBUILDER_TEMPLATE_DYNAMIC_GET_DESCRIPTION"
|
||||
multiple="false"
|
||||
required="true"
|
||||
required="false"
|
||||
button="true"
|
||||
/>
|
||||
<!-- Not_required Field. Type: Hidden. (joomla) -->
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage import.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.4.0
|
||||
@build 31st March, 2017
|
||||
@version 2.4.1
|
||||
@build 1st April, 2017
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage import_joomla_components.php
|
||||
@ -89,6 +89,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
protected $updateAfter = array('field' => array(), 'adminview' => array());
|
||||
protected $fieldTypes = array();
|
||||
protected $isRepeatable = array();
|
||||
protected $specialValue = false;
|
||||
|
||||
/**
|
||||
* Import an spreadsheet from either folder, url or upload.
|
||||
@ -715,6 +716,8 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
**/
|
||||
protected function moveSmartStuff($dir)
|
||||
{
|
||||
// make sure to first unlock files
|
||||
$this->unLockFiles($dir);
|
||||
// set params
|
||||
$params = JComponentHelper::getParams('com_componentbuilder');
|
||||
// set custom folder path
|
||||
@ -744,6 +747,66 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unlock all files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function unLockFiles(&$dir)
|
||||
{
|
||||
// lock the data if set
|
||||
if(ComponentbuilderHelper::checkString($this->sleutle) && strlen($this->sleutle) == 32)
|
||||
{
|
||||
$unlocker = new FOFEncryptAes($this->sleutle, 128);
|
||||
// we must first store the current working directory
|
||||
$joomla = getcwd();
|
||||
// setup the type path
|
||||
$customPath = $dir . '/custom';
|
||||
// go to the custom folder if found
|
||||
if (JFolder::exists($customPath))
|
||||
{
|
||||
$this->unlock($customPath, $unlocker);
|
||||
}
|
||||
// setup the type path
|
||||
$imagesPath = $dir . '/images';
|
||||
// go to the custom folder if found
|
||||
if (JFolder::exists($imagesPath))
|
||||
{
|
||||
$this->unlock($imagesPath, $unlocker);
|
||||
}
|
||||
// change back to working dir
|
||||
chdir($joomla);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Unlocker
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function unlock(&$tmpPath, &$unlocker)
|
||||
{
|
||||
// we are changing the working directory to the tmp path (important)
|
||||
chdir($tmpPath);
|
||||
// get a list of files in the current directory tree (all)
|
||||
$files = JFolder::files('.', '.', true, true);
|
||||
// read in the file content
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// check that the string is base64
|
||||
$data = str_replace("\n", '', file_get_contents($file));
|
||||
if ($data === base64_encode(base64_decode($data, true)))
|
||||
{
|
||||
// write the decrypted data back to file
|
||||
if (!ComponentbuilderHelper::writeFile($file, rtrim($unlocker->decryptString($data), "\0")))
|
||||
{
|
||||
// we should add error handler here in case file could not be unlocked
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the smart items
|
||||
*
|
||||
@ -775,7 +838,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
$oldID = $item->id;
|
||||
// first check if exist
|
||||
if ($local = $this->getLocalItem($item, $type, $db, true))
|
||||
if ($local = $this->getLocalItem($item, $type, $db, 1))
|
||||
{
|
||||
$dbDate = strtotime($item->modified);
|
||||
$localDate = strtotime($local->modified);
|
||||
@ -1550,17 +1613,25 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
{
|
||||
if (isset($item->$field))
|
||||
{
|
||||
if (is_numeric($item->$field) && is_int($item->$field))
|
||||
// set the value
|
||||
$value = $item->$field;
|
||||
// check if we have special value
|
||||
if ($this->specialValue && ComponentbuilderHelper::checkArray($this->specialValue) && isset($this->specialValue[$field]))
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $field) . ' = '. (int) $item->$field);
|
||||
$value = $this->specialValue[$field];
|
||||
}
|
||||
elseif (is_numeric($item->$field) && is_float($item->$field))
|
||||
// load to query
|
||||
if (is_numeric($value) && is_int($value))
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $field) . ' = '. (float) $item->$field);
|
||||
$query->where($db->quoteName('a.' . $field) . ' = '. (int) $value);
|
||||
}
|
||||
elseif(componentbuilderHelper::checkString($item->$field)) // do not allow empty strings (since it could be major mis match)
|
||||
elseif (is_numeric($value) && is_float($value))
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $field) . ' = '. $db->quote($item->$field));
|
||||
$query->where($db->quoteName('a.' . $field) . ' = '. (float) $value);
|
||||
}
|
||||
elseif(componentbuilderHelper::checkString($value)) // do not allow empty strings (since it could be major mis match)
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $field) . ' = '. $db->quote($value));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1573,25 +1644,40 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($item->$get) && componentbuilderHelper::checkString($item->$get)) // do not allow empty strings (since it could be major mis match)
|
||||
{
|
||||
// set the value
|
||||
$value = $item->$get;
|
||||
// check if we have special value
|
||||
if ($this->specialValue && ComponentbuilderHelper::checkArray($this->specialValue) && isset($this->specialValue[$get]))
|
||||
{
|
||||
$value = $this->specialValue[$get];
|
||||
}
|
||||
$query->where($db->quoteName('a.' . $get) . ' = '. $db->quote($value));
|
||||
}
|
||||
elseif (isset($item->$get) && is_numeric($item->$get))
|
||||
{
|
||||
if (is_int($item->$get))
|
||||
// set the value
|
||||
$value = $item->$get;
|
||||
// check if we have special value
|
||||
if ($this->specialValue && ComponentbuilderHelper::checkArray($this->specialValue) && isset($this->specialValue[$get]))
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $get) . ' = '. (int) $item->$get);
|
||||
$value = $this->specialValue[$get];
|
||||
}
|
||||
elseif (is_float($item->$get))
|
||||
// load to query
|
||||
if (is_int($value))
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $get) . ' = '. (float) $item->$get);
|
||||
$query->where($db->quoteName('a.' . $get) . ' = '. (int) $value);
|
||||
}
|
||||
elseif (is_float($value))
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $get) . ' = '. (float) $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // really not needed but who knows for sure...
|
||||
}
|
||||
}
|
||||
elseif (isset($item->$get) && componentbuilderHelper::checkString($item->$get)) // do not allow empty strings (since it could be major mis match)
|
||||
{
|
||||
$query->where($db->quoteName('a.' . $get) . ' = '. $db->quote($item->$get));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
@ -1606,6 +1692,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
elseif ($retry)
|
||||
{
|
||||
$retryAgain = false;
|
||||
$this->specialValue = false;
|
||||
// set the getter
|
||||
switch ($type)
|
||||
{
|
||||
@ -1615,12 +1702,40 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
|
||||
break;
|
||||
case 'field':
|
||||
// get by name and xml to target correct field
|
||||
$getter = array('name', 'xml'); // risky will look at this again (to add fieldtype)
|
||||
if ($retry == 2)
|
||||
{
|
||||
// get by id name..
|
||||
$getter = array('name','datatype','store','indexes','null_switch','xml');
|
||||
}
|
||||
else
|
||||
{
|
||||
// get by id name..
|
||||
$getter = array('name','datatype','store','indexes','null_switch');
|
||||
// lets try to add the fieldtype
|
||||
if (isset($item->fieldtype) && is_numeric($item->fieldtype) && $item->fieldtype > 0 && isset($this->newID['fieldtype'][$item->fieldtype]) && $this->newID['fieldtype'][$item->fieldtype] > 0)
|
||||
{
|
||||
$getter[] = 'fieldtype';
|
||||
$this->specialValue = array();
|
||||
$this->specialValue['fieldtype'] = $this->newID['fieldtype'][$item->fieldtype];
|
||||
$retryAgain = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$getter[] = 'xml';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'site_view':
|
||||
case 'custom_admin_view':
|
||||
// get by name, system_name and codename
|
||||
$getter = array('name', 'system_name', 'codename'); // risky will look at this again (to add main_get)
|
||||
$getter = array('name', 'system_name', 'codename');
|
||||
// lets try to add the main_get
|
||||
if (isset($item->main_get) && is_numeric($item->main_get) && $item->main_get > 0 && isset($this->newID['dynamic_get'][$item->main_get]) && $this->newID['dynamic_get'][$item->main_get] > 0)
|
||||
{
|
||||
$getter[] = 'main_get';
|
||||
$this->specialValue = array();
|
||||
$this->specialValue['main_get'] = $this->newID['dynamic_get'][$item->main_get];
|
||||
}
|
||||
break;
|
||||
case 'template':
|
||||
case 'layout':
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 297 of this MVC
|
||||
@build 31st March, 2017
|
||||
@version @update number 311 of this MVC
|
||||
@build 1st April, 2017
|
||||
@created 6th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage joomla_component.php
|
||||
|
@ -10,8 +10,8 @@
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 297 of this MVC
|
||||
@build 31st March, 2017
|
||||
@version @update number 311 of this MVC
|
||||
@build 1st April, 2017
|
||||
@created 6th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage joomla_components.php
|
||||
@ -292,6 +292,8 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// lock all files
|
||||
$this->lockFiles();
|
||||
// remove old zip files with the same name
|
||||
if (JFile::exists($this->zipPath))
|
||||
{
|
||||
@ -311,6 +313,60 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to lock all files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function lockFiles()
|
||||
{
|
||||
// lock the data if set
|
||||
if (ComponentbuilderHelper::checkString($this->key) && strlen($this->key) == 32)
|
||||
{
|
||||
$locker = new FOFEncryptAes($this->key, 128);
|
||||
// we must first store the current working directory
|
||||
$joomla = getcwd();
|
||||
// setup the type path
|
||||
$customPath = $this->packagePath . '/custom';
|
||||
// go to the custom folder if found
|
||||
if (JFolder::exists($customPath))
|
||||
{
|
||||
$this->lock($customPath, $locker);
|
||||
}
|
||||
// setup the type path
|
||||
$imagesPath = $this->packagePath . '/images';
|
||||
// go to the custom folder if found
|
||||
if (JFolder::exists($imagesPath))
|
||||
{
|
||||
$this->lock($imagesPath, $locker);
|
||||
}
|
||||
// change back to working dir
|
||||
chdir($joomla);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Locker
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function lock(&$tmpPath, &$locker)
|
||||
{
|
||||
// we are changing the working directory to the tmp path (important)
|
||||
chdir($tmpPath);
|
||||
// get a list of files in the current directory tree (all)
|
||||
$files = JFolder::files('.', '.', true, true);
|
||||
// read in the file content
|
||||
foreach ($files as $file)
|
||||
{
|
||||
// write the encrypted string back to file
|
||||
if (!ComponentbuilderHelper::writeFile($file, wordwrap($locker->encryptString(file_get_contents($file)), 128, "\n", true)))
|
||||
{
|
||||
// we should add error handler here in case file could not be locked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to move the files and folder to the package folder
|
||||
*
|
||||
@ -838,7 +894,14 @@ class ComponentbuilderModelJoomla_components extends JModelList
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
return ComponentbuilderHelper::safeString($item->name_code);
|
||||
if (isset($item->system_name))
|
||||
{
|
||||
return ComponentbuilderHelper::safeString($item->system_name, 'cAmel');
|
||||
}
|
||||
else
|
||||
{
|
||||
return ComponentbuilderHelper::safeString($item->name_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 67 of this MVC
|
||||
@build 22nd February, 2017
|
||||
@build 1st April, 2017
|
||||
@created 18th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage layout.php
|
||||
|
@ -11,7 +11,7 @@
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 67 of this MVC
|
||||
@build 22nd February, 2017
|
||||
@build 1st April, 2017
|
||||
@created 18th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage layouts.php
|
||||
|
@ -11,7 +11,7 @@
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 40 of this MVC
|
||||
@build 22nd February, 2017
|
||||
@build 1st April, 2017
|
||||
@created 26th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage template.php
|
||||
|
@ -11,7 +11,7 @@
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version @update number 40 of this MVC
|
||||
@build 22nd February, 2017
|
||||
@build 1st April, 2017
|
||||
@created 26th May, 2015
|
||||
@package Component Builder
|
||||
@subpackage templates.php
|
||||
|
Reference in New Issue
Block a user