Skip to content

Commit

Permalink
Merge pull request techjoomla#204 from techjoomla/release-1.4.3
Browse files Browse the repository at this point in the history
Release 1.4.3
  • Loading branch information
ankush-maherwal authored Nov 4, 2019
2 parents b81ce48 + 02e33be commit 0854c9d
Show file tree
Hide file tree
Showing 35 changed files with 634 additions and 249 deletions.
2 changes: 1 addition & 1 deletion admin_language/en-GB/en-GB.com_tjfields.ini
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ COM_TJFIELDS_FORM_DESC_EDITOR_WIDTH="Set width"
COM_TJFIELDS_FORM_LBL_EDITOR_HEIGHT="Height"
COM_TJFIELDS_FORM_DESC_EDITOR_HEIGHT="Set height"
COM_TJFIELDS_FORM_LBL_FIELD_SIZE="Size"
COM_TJFIELDS_FORM_DESC_FIELD_SIZE="Set maximum allowed file size (In MB) e.g 10, 20"
COM_TJFIELDS_FORM_DESC_FIELD_SIZE="Set size"
COM_TJFIELDS_FORM_LBL_FIELD_MAXLENGTH="Max Length"
COM_TJFIELDS_FORM_LBL_FIELD_MIN="Min Value"
COM_TJFIELDS_FORM_DESC_FIELD_MIN="Min Value"
Expand Down
15 changes: 1 addition & 14 deletions administrator/assets/js/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,8 @@ techjoomla.jQuery( document ).ready(function(){
// show the default path for file upload & attach the folder name with respect to name entered for file field
if (field_type == 'file')
{
// folder name should contain only alpahnumeric characters & also remove the underscores and spaces
if(field_id==0)
if(field_id != 0)
{
techjoomla.jQuery('#jform_params_uploadpath').val(fileUploadDefaultPath+client+"/");
techjoomla.jQuery("#jform_name").keyup(function(){
techjoomla.jQuery('#jform_params_uploadpath').val(fileUploadDefaultPath+client+"_"+clientType+"_"+techjoomla.jQuery("#jform_name").val().replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '')+"/");
});
}
else
{
if (techjoomla.jQuery('#jform_params_uploadpath').val()=="")
{
techjoomla.jQuery('#jform_params_uploadpath').val(fileUploadDefaultPath+client+"/"+clientType+"/");
}

// Show current file upload path & notice to admin user in case if he is going to custmozie the file upload path
techjoomla.jQuery('#currentUploadPath').html(techjoomla.jQuery('#jform_params_uploadpath').val());
var fileUploadhtml = techjoomla.jQuery('.fileUploadAlert').html();
Expand Down
2 changes: 1 addition & 1 deletion administrator/controllers/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function newsave()
{
$msg = JText::_('COMTJFILEDS_GROUP_CREATED_SUCCESSFULLY');
$link = JRoute::_('index.php?option=com_tjfields&view=group&layout=edit&client=' . $input->get('client', '', 'STRING'), false);
$this->setRedirect($link, $msg, 'error');
$this->setRedirect($link, $msg, 'success');
}
else
{
Expand Down
81 changes: 49 additions & 32 deletions administrator/houseKeeping/1.5.0/fieldDefaultValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,48 +32,65 @@ class TjHouseKeepingFieldDefaultValue extends TjModelHouseKeeping
*/
public function migrate()
{
$db = JFactory::getDbo();
JLoader::import('components.com_tjfields.tables.option', JPATH_ADMINISTRATOR);
$optionTable = Table::getInstance('Option', 'TjfieldsTable', array('dbo', $db));
$optionTableColumns = $optionTable->getFields();
$result = array();

// No migration needed if the default_option column is already removed
if (!array_key_exists('default_option', $optionTableColumns))
try
{
return true;
}
$db = JFactory::getDbo();
JLoader::import('components.com_tjfields.tables.option', JPATH_ADMINISTRATOR);
$optionTable = Table::getInstance('Option', 'TjfieldsTable', array('dbo', $db));
$optionTableColumns = $optionTable->getFields();

$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__tjfields_options'));
$query->where($db->quoteName('default_option') . '=1');
$db->setQuery($query);
$fieldOptions = $db->loadObjectList();
// No migration needed if the default_option column is already removed
if (!array_key_exists('default_option', $optionTableColumns))
{
$result['status'] = true;
$result['message'] = "Migration successful";

if (!empty($fieldOptions))
{
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
$fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db));
return $result;
}

$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__tjfields_options'));
$query->where($db->quoteName('default_option') . '=1');
$db->setQuery($query);
$fieldOptions = $db->loadObjectList();

foreach ($fieldOptions as $fieldOption)
if (!empty($fieldOptions))
{
if (!empty($fieldOption->default_option))
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
$fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db));

foreach ($fieldOptions as $fieldOption)
{
$fieldTable->load($fieldOption->field_id);
$fieldParams = json_decode($fieldTable->params);
$fieldParams->default = $fieldOption->value;
$fieldTable->params = json_encode($fieldParams);
$fieldTable->store();
if (!empty($fieldOption->default_option))
{
$fieldTable->load($fieldOption->field_id);
$fieldParams = json_decode($fieldTable->params);
$fieldParams->default = $fieldOption->value;
$fieldTable->params = json_encode($fieldParams);
$fieldTable->store();
}
}
}
}

// Drop 'default_option' column from options table
$query = $db->getQuery(true);
$query = "ALTER TABLE `#__tjfields_options` DROP `default_option`";
$db->setQuery($query);
$db->execute();
// Drop 'default_option' column from options table
$query = $db->getQuery(true);
$query = "ALTER TABLE `#__tjfields_options` DROP `default_option`";
$db->setQuery($query);
$db->execute();

$result['status'] = true;
$result['message'] = "Migration successful";
}
catch (Exception $e)
{
$result['err_code'] = '';
$result['status'] = false;
$result['message'] = $e->getMessage();
}

return true;
return $result;
}
}
23 changes: 22 additions & 1 deletion administrator/models/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getForm($data = array(), $loadData = true)
}
}

if ($form->getValue('type') == 'ucmsubform')
if ($form->getValue('type') == 'ucmsubform' || $form->getValue('type') == 'subform')
{
$form->setValue('showonlist', null, 0);
$form->removeField('showonlist');
Expand Down Expand Up @@ -796,4 +796,25 @@ public function delete(&$pks)

return true;
}

/**
* Method to get JForm for subform field.
*
* @param STRING $name name of the form
* @param STRING $formSource form source path
* @param OBJECT $loadData data to be loaded
*
* @return mixed JForm object if successful, false if an error occurs.
*
* @since 1.4.3
*/
public function getSubFormFieldForm($name, $formSource, $loadData = array())
{
if (empty($name) || empty($formSource) || !JFile::exists($formSource))
{
return false;
}

return $this->loadForm($name, $formSource, array('control' => 'jform','load_data' => $loadData));
}
}
2 changes: 1 addition & 1 deletion administrator/models/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function getListQuery()
else
{
$search = $db->Quote('%' . $db->escape($search, true) . '%');
$query->where('( a.type LIKE ' . $search . ' )');
$query->where('( a.label LIKE ' . $search . ' )');
}
}

Expand Down
10 changes: 0 additions & 10 deletions administrator/models/fields/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,6 @@ protected function buildData($layoutData)
$data->fields_value_table = JTable::getInstance('Fieldsvalue', 'TjfieldsTable');
$data->fields_value_table->load(array('value' => $layoutData['value']));

if ($data->isSubformField)
{
// Getting field value of subform file field using the content_id from url and subform_id which will be the field id
$data->fields_value_table->load(array('content_id' => $formValueId, 'field_id' => $data->subformId));
}
else
{
$data->fields_value_table->load(array('value' => $layoutData['value']));
}

$extraParamArray = array();
$extraParamArray['id'] = $data->fields_value_table->id;

Expand Down
54 changes: 54 additions & 0 deletions administrator/models/fields/fileuploadpath.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @version SVN:<SVN_ID>
* @package TJFields
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved
* @license GNU General Public License version 2, or later
*/

defined('JPATH_PLATFORM') or die;

JFormHelper::loadFieldClass('textarea');

/**
* Form Field Textareacounter class
* Supports a multi line area for entry of plain text with count char
*
* @since 11.1
*/
class JFormFieldFileUploadPath extends JFormFieldTextarea
{
/**
* The form field type.
*
* @var string
* @since 11.1
*/
protected $type = 'Fileuploadpath';

/**
* Method to get the textarea field input markup.
* Use the rows and columns attributes to specify the dimensions of the area.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput()
{
$layoutData = $this->getLayoutData();
$client = $layoutData['field']->form->getData()->get('client');
$client = str_replace('.', '_', $client);

if (empty($this->value))
{
$this->value = JPATH_SITE . '/media/' . $client . '/';
$this->value = str_replace('/', DIRECTORY_SEPARATOR, $this->value);
}

$html = parent::getInput();

return $html;
}
}
2 changes: 1 addition & 1 deletion administrator/models/fields/related.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class JFormFieldRelated extends JFormFieldList
*
* @since 3.7.0
*/
protected function getOptions()
public function getOptions()
{
// Load TJ-Fields language file
$lang = Factory::getLanguage()->load('com_tjfields', JPATH_ADMINISTRATOR);
Expand Down
Loading

0 comments on commit 0854c9d

Please sign in to comment.