Skip to content

Commit

Permalink
Add tag functionality for Joomla 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
mastervanleeuwen committed Aug 25, 2024
1 parent 6b819c0 commit 87f2467
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
1 change: 0 additions & 1 deletion administrator/components/com_jtg/tables/jtg_cats.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class TableJTG_Cats extends JTable
public function __construct(& $db)
{
parent::__construct('#__jtg_cats', 'id', $db);
$this->typeAlias = 'com_jtg.category';
}

/**
Expand Down
8 changes: 7 additions & 1 deletion administrator/components/com_jtg/tables/jtg_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ class TableJTG_Files extends Table implements TaggableTableInterface
public function __construct(& $db)
{
parent::__construct('#__jtg_files', 'id', $db);
$this->typeAlias = 'com_jtg.file';
if (version_compare(JVERSION,'4.0','ge')) {
$this->typeAlias = 'com_jtg.file';
}
else {
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'TableJTG_Files', array('typeAlias' => 'com_jtg.file'));
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_jtg.file'));
}
}

function getTypeAlias() { return 'com_jtg.file'; }
Expand Down
9 changes: 7 additions & 2 deletions administrator/components/com_jtg/views/files/tmpl/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
JToolBarHelper::deleteList('COM_JTG_VALIDATE_DELETE_ITEMS', 'removeFromImport');
JToolBarHelper::help('files/import', true);
$document = JFactory::getDocument();
$style = " #row00 {--table-bg: #FFFF99;}\n";
$style = " #row00 {--table-bg: #FFFF99; background-color: #FFFF99;}\n";
$style .= " .table-admin {--table-bg: var(--admin-background);}\n";

if (version_compare(JVERSION, '3.0', 'ge'))
Expand Down Expand Up @@ -124,7 +124,12 @@ class="adminForm" enctype="multipart/form-data">
// . JText::_('COM_JTG_PRESELECTION_DESCRIPTION') . "</td>
$trackForm = $this->getModel()->getForm();
$tagField = $trackForm->getField('tags');
$tagField->__set('onchange',"setSelectTags('tags')");
if (version_compare(JVERSION, '4.0', 'ge')) {
$tagField->__set('onchange',"setSelectTags('tags')");
}
else {
$tagField->__set('onchange',"setSelectMultiple('tags')");
}
$tagField->__set('name',"tags_all");
$tagField->__set('id',"tags_all");
$table = (" <tbody>\n
Expand Down
8 changes: 7 additions & 1 deletion administrator/components/com_jtg/views/files/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,13 @@ protected function _displayForm($tpl)
$lists['published'] = JHtml::_('select.booleanlist', 'published', null, $track->published);
$lists['values'] = JtgHelper::giveGeneratedValues('backend', $this->buildImageFiletypes($track->istrack, $track->iswp, $track->isroute, $track->iscache), $track);
$lists['level'] = $model->getLevelList($track->level);
$this->tagids = $model->getTable('jtg_files')->getTagsHelper()->getTagIds($id, 'com_jtg.file');
if (version_compare(JVERSION,'4.0','ge')) {
$this->tagids = $model->getTable('jtg_files')->getTagsHelper()->getTagIds($id, 'com_jtg.file');
}
else {
$tagsHelper = new JHelperTags;
$this->tagids = $tagsHelper->getTagIds($id, 'com_jtg.file');
}
$trackForm = $this->getModel()->getForm();
$tagField = $trackForm->getField('tags');
$tagField->setValue($this->tagids);
Expand Down
2 changes: 1 addition & 1 deletion com_jtg.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="4.0" method="upgrade">
<extension type="component" version="3.10" method="upgrade">
<name>com_jtg</name>
<author>J!Track Gallery, InJoo0SM and joomGPStracks teams</author>
<creationDate>22.04.2011</creationDate>
Expand Down
8 changes: 2 additions & 6 deletions components/com_jtg/models/track.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
jimport('joomla.application.component.model');
use Joomla\CMS\Factory;
use Joomla\CMS\Editor\Editor;
use Joomla\CMS\MVC\Model\ItemModel;
use Joomla\CMS\MVC\Model\FormBehaviorTrait;
use Joomla\CMS\MVC\Model\FormModel;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Form\FormFactoryAwareTrait;

/**
* JtgModelTrack class for the jtg component
Expand All @@ -34,10 +32,8 @@
*/


class JtgModelTrack extends ItemModel
class JtgModelTrack extends FormModel
{
use FormFactoryAwareTrait;
use FormBehaviorTrait;

public function getForm($data = array(), $loadData = true)
{
Expand Down
13 changes: 10 additions & 3 deletions components/com_jtg/views/track/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function display($tpl = null)
jimport('joomla.filesystem.folder');

// Code support for joomla version greater than 3.0
if (JVERSION >= 3.0)
if (version_compare(JVERSION,'3.0','ge'))
{
JHtml::_('jquery.framework');
JHtml::script(Juri::base() . 'components/com_jtg/assets/js/jquery.MultiFile.js');
Expand Down Expand Up @@ -232,8 +232,15 @@ public function display($tpl = null)
$this->elevationDataExists = $gpsData->elevationDataExists;
$this->beatDataExists = $gpsData->beatDataExists;

$this->tags = $model->getTable('jtg_files')->getTagsHelper()->getItemTags('com_jtg.file' , $this->id);
$this->tagids = $model->getTable('jtg_files')->getTagsHelper()->getTagIds($this->id, 'com_jtg.file');
if (version_compare(JVERSION,'4.0','ge')) {
$this->tags = $model->getTable('jtg_files')->getTagsHelper()->getItemTags('com_jtg.file' , $this->id);
$this->tagids = $model->getTable('jtg_files')->getTagsHelper()->getTagIds($this->id, 'com_jtg.file');
}
else {
$tagsHelper = new JHelperTags;
$this->tags = $tagsHelper->getItemTags('com_jtg.file' , $this->id);
$this->tagids = $tagsHelper->getTagIds($this->id, 'com_jtg.file');
}

if ( count($this->imageList) > 0) {
$this->images = true;
Expand Down

0 comments on commit 87f2467

Please sign in to comment.