Skip to content

Commit

Permalink
Merge pull request #342 from ankush-maherwal/joomla-4
Browse files Browse the repository at this point in the history
Task #173069 feat: Update infra extensions code used in JGive to make…
  • Loading branch information
ankush-maherwal authored Dec 8, 2021
2 parents 6391ad9 + a0b8e64 commit 3e9652d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 4 deletions.
2 changes: 1 addition & 1 deletion administrator/houseKeeping/1.5.0/fieldDefaultValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

// No direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;


/**
* Migration file for TJ-Fields
*
Expand Down
66 changes: 66 additions & 0 deletions administrator/houseKeeping/2.0.0/fileFieldFix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* @package TJ-Fields
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
*/

// No direct access
defined('_JEXEC') or die('Restricted access');

use Joomla\CMS\Factory;

/**
* Migration file for TJ-Fields
*
* @since 1.0
*/
class TjHouseKeepingFileFieldFix extends TjModelHouseKeeping
{
public $title = "Update File field with TJFile field";

public $description = "Remove file field class used for TJ-FIelds and replace it with TJ-File field";

/**
* Default value migration script
*
* @return void
*
* @since 1.0
*/
public function migrate()
{
$result = array();

try
{
$db = Factory::getDbo();
$query = $db->getQuery(true);

$fields = array(
$db->quoteName('type') . ' = ' . $db->quote('tjfile')
);

$conditions = array(
$db->quoteName('type') . ' = ' . $db->quote('file')
);

$query->update($db->quoteName('#__tjfields_fields'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();

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

return $result;
}
}
4 changes: 1 addition & 3 deletions administrator/models/fields/tjfieldfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class JFormFieldtjfieldfields extends JFormFieldList
*/
protected function getInput()
{
jimport('joomla.filesystem.file');

$installUcm = 0;

$installCluster = 0;
Expand Down Expand Up @@ -74,7 +72,7 @@ protected function getInput()
$options[] = HTMLHelper::_('select.option', 'calendar', Text::_('COM_TJFIELDS_CALENDAR'));
$options[] = HTMLHelper::_('select.option', 'editor', Text::_('COM_TJFIELDS_EDITOR'));
$options[] = HTMLHelper::_('select.option', 'email', Text::_('COM_TJFIELDS_EMAIL'));
$options[] = HTMLHelper::_('select.option', 'file', Text::_('COM_TJFIELDS_FILE'));
$options[] = HTMLHelper::_('select.option', 'tjfile', Text::_('COM_TJFIELDS_FILE'));
$options[] = HTMLHelper::_('select.option', 'spacer', Text::_('COM_TJFIELDS_SPACER'));
$options[] = HTMLHelper::_('select.option', 'subform', Text::_('COM_TJFIELDS_SUBFORM'));
$options[] = HTMLHelper::_('select.option', 'image', Text::_('COM_TJFIELDS_IMAGE'));
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions script.tjfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ public function preflight($type, $parent)
{
File::delete(JPATH_SITE . '/administrator/components/com_tjfields/sql/updates/mysql/1.3.1.sql');
}

// Delete file field class if exists as this is replaced by tjfile.php
if (File::exists(JPATH_SITE . '/administrator/components/com_tjfields/models/fields/file.php'))
{
File::delete(JPATH_SITE . '/administrator/components/com_tjfields/models/fields/file.php');
}

// Delete file field xml if exists as this is replaced by tjfile.xml
if (File::exists(JPATH_SITE . '/administrator/components/com_tjfields/models/forms/types/forms/file.xml'))
{
File::delete(JPATH_SITE . '/administrator/components/com_tjfields/models/forms/types/forms/file.xml');
}
}

/**
Expand Down

0 comments on commit 3e9652d

Please sign in to comment.