Skip to content

Commit

Permalink
Merge pull request #382 from punambaravkar/upgrade
Browse files Browse the repository at this point in the history
Task #228684 chore: Bug - While creating and displaying file and image field  giving error
  • Loading branch information
vaibhavsTekdi authored Oct 17, 2024
2 parents 1730881 + 0b6f7ed commit c871326
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 5 additions & 5 deletions administrator/models/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,19 @@ public function save($data)
// Remove extra value which are not needed to save in the fields table
$TjfieldsHelper = new TjfieldsHelper;

if (array_key_exists("accept",$data['params']))
if (isset($data['params']) && is_array($data['params']) && array_key_exists("accept", $data['params']))
{
$data['params']['accept'] = preg_replace('/\s+/', '', $data['params']['accept']);
}

if (array_key_exists("uploadpath", $data['params']))
{
if (isset($data['params']) && is_array($data['params']) && array_key_exists("uploadpath", $data['params'])) {

// Rename the .htaccess file if the file renderer is changed to preview
$htaccessFile = $data['params']['uploadpath'] . '/' . $this->htaccess;
}

if (array_key_exists("renderer", $data['params']) && $data['params']['renderer'] == 'preview')
{
if (isset($data['params']) && is_array($data['params']) && array_key_exists("renderer", $data['params']) && $data['params']['renderer'] == 'preview')
{
if (!empty($htaccessFile) && File::exists($htaccessFile))
{
// Rename the .htaccess file if the renderer is preview
Expand Down
4 changes: 2 additions & 2 deletions administrator/models/fields/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

JLoader::import('components.com_tjfields.models.fields.file', JPATH_ADMINISTRATOR);
JLoader::import('components.com_tjfields.models.fields.tjfile', JPATH_ADMINISTRATOR);

/**
* Form Field Image class
* Supports a multi line area for entry of plain text with count char
*
* @since __DEPLOY_VERSION__
*/
class JFormFieldImage extends JFormFieldFile
class JFormFieldImage extends JFormFieldTjFile
{
/**
* The form field type.
Expand Down
11 changes: 10 additions & 1 deletion administrator/models/fields/tjfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,16 @@ protected function canDownloadFile($data, $layoutData)

if ($data->fields_value_table->value)
{
$fileTitle = substr($data->fields_value_table->value, strpos($data->fields_value_table->value, '_', 12) + 1);
$value = $data->fields_value_table->value;

if (strlen($value) > $offset)
{
$fileTitle = substr($value, strpos($value, '_', 12) + 1);
}
else
{
$fileTitle = $value;
}
}

if ($renderer == 'download')
Expand Down

0 comments on commit c871326

Please sign in to comment.