Skip to content

Commit

Permalink
Task #173069 feat: Update infra extensions code used to make Joomla 4…
Browse files Browse the repository at this point in the history
… compatible (#57)
  • Loading branch information
ankush-maherwal authored Jan 25, 2022
1 parent c179ef0 commit 6cf6c53
Show file tree
Hide file tree
Showing 25 changed files with 170 additions and 114 deletions.
6 changes: 3 additions & 3 deletions plugins/api/tjactivity/tjactivity.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="plugin" group="api" method="upgrade">
<name>com_api_tjactivity</name>
<version>1.0.3</version>
<creationDate>22nd Jul 2021</creationDate>
<version>2.0.0</version>
<creationDate>25th Jan 2022</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.</copyright>
<copyright>Copyright (C) 2016 - 2022 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>PLG_API_TJACTIVITY_DESCRIPTION</description>
<languages>
Expand Down
6 changes: 3 additions & 3 deletions src/activitystream.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.0" method="upgrade">
<name>com_activitystream</name>
<creationDate>22nd Jul 2021</creationDate>
<creationDate>25th Jan 2022</creationDate>
<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.</copyright>
<copyright>Copyright (C) 2016 - 2022 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<version>1.0.3</version>
<version>2.0.0</version>
<description>COM_ACTIVITYSTREAM_DESCRIPTION</description>
<scriptfile>script.activitystream.php</scriptfile>
<install>
Expand Down
6 changes: 4 additions & 2 deletions src/admin/activitystream.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Factory;

// Get an instance of the controller prefixed by HelloWorld
$controller = JControllerLegacy::getInstance('activitystream');
$controller = BaseController::getInstance('activitystream');

// Perform the Request task
$input = JFactory::getApplication()->input;
$input = Factory::getApplication()->input;
$controller->execute($input->getCmd('task'));

// Redirect if set by the controller
Expand Down
3 changes: 2 additions & 1 deletion src/admin/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;

/**
* General Controller of ActivityStream component
Expand All @@ -17,7 +18,7 @@
* @subpackage com_activitystream
* @since 0.0.7
*/
class ActivityStreamController extends JControllerLegacy
class ActivityStreamController extends BaseController
{
/**
* The default view for the display method.
Expand Down
28 changes: 17 additions & 11 deletions src/admin/controllers/activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Router\Route;
use Joomla\Utilities\ArrayHelper;

/**
* Activity Stream Controller
*
* @since 0.0.1
*/
class ActivityStreamControllerActivities extends JControllerAdmin
class ActivityStreamControllerActivities extends AdminController
{
/**
* Proxy for getModel.
Expand Down Expand Up @@ -44,7 +50,7 @@ public function getModel($name = 'Activity', $prefix = 'ActivityStreamModel', $c
public function getActivities()
{
// Load component tables
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_activitystream/tables');
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_activitystream/tables');

// Variable to store activity data fetched
$result = array();
Expand All @@ -54,14 +60,14 @@ public function getActivities()

$ActivityStreamModelActivities = $this->getModel('Activities');

$jinput = JFactory::getApplication()->input;
$jinput = Factory::getApplication()->input;
$type = $jinput->get("type", '', 'STRING');

// Return result related to specified activity type
if (empty($type))
{
$result_arr['success'] = false;
$result_arr['message'] = JText::_("COM_ACTIVITYSTREAM_ERROR_ACTIVITY_TYPE");
$result_arr['message'] = Text::_("COM_ACTIVITYSTREAM_ERROR_ACTIVITY_TYPE");

echo json_encode($result_arr);

Expand Down Expand Up @@ -90,7 +96,7 @@ public function getActivities()
if (empty($result['results']))
{
$result_arr['success'] = false;
$result_arr['message'] = JText::_("COM_ACTIVITYSTREAM_NO_ACTIVITY");
$result_arr['message'] = Text::_("COM_ACTIVITYSTREAM_NO_ACTIVITY");
}
else
{
Expand All @@ -113,13 +119,13 @@ public function getActivities()
*/
public function delete()
{
$input = JFactory::getApplication()->input;
$input = Factory::getApplication()->input;
$client = $input->get('client', '', 'STRING');
$id = JFactory::getApplication()->input->get('cid', array(), 'array');
$id = Factory::getApplication()->input->get('cid', array(), 'array');

if (!is_array($id) || count($id) < 1)
{
JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
Log::add(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), Log::WARNING, 'jerror');
}
else
{
Expand All @@ -133,7 +139,7 @@ public function delete()
// Remove the activity.
if ($model->delete($id))
{
$this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($id)));
$this->setMessage(Text::plural($this->text_prefix . '_N_ITEMS_DELETED', count($id)));
}
else
{
Expand All @@ -142,11 +148,11 @@ public function delete()

if (isset($client))
{
$this->setRedirect(JRoute::_('index.php?option=com_activitystream&view=activities&client=' . $client, false));
$this->setRedirect(Route::_('index.php?option=com_activitystream&view=activities&client=' . $client, false));
}
else
{
$this->setRedirect(JRoute::_('index.php?option=com_activitystream&view=activities', false));
$this->setRedirect(Route::_('index.php?option=com_activitystream&view=activities', false));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/admin/controllers/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\FormController;

/**
* HelloWorld Controller
Expand All @@ -16,6 +17,6 @@
* @subpackage com_activitystream
* @since 0.0.9
*/
class ActivityStreamControllerActivity extends JControllerForm
class ActivityStreamControllerActivity extends FormController
{
}
3 changes: 2 additions & 1 deletion src/admin/helpers/activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// No direct access
defined('_JEXEC') or die();
use Joomla\CMS\Factory;

/**
* Products helper for quick2cart backend.
Expand Down Expand Up @@ -87,7 +88,7 @@ public function json_to_array($array, $recursive = true)
*/
public function buildActivityFilterQuery($filterString)
{
$db = JFactory::getDbo();
$db = Factory::getDbo();

// Check if $filterString is comma separated string.
if ((strpos($filterString, ',') !== false))
Expand Down
13 changes: 8 additions & 5 deletions src/admin/models/activities.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;

/**
* ActivityStreamList Model
*
* @since 0.0.1
*/
class ActivityStreamModelActivities extends JModelList
class ActivityStreamModelActivities extends ListModel
{
/**
* Constructor.
Expand Down Expand Up @@ -60,7 +63,7 @@ public function __construct($config = array())
protected function populateState($ordering = 'id', $direction = 'desc')
{
// Initialise variables.
$jinput = JFactory::getApplication()->input;
$jinput = Factory::getApplication()->input;

// Client filter
$extension = $jinput->get("client", '', 'STRING');
Expand Down Expand Up @@ -94,7 +97,7 @@ protected function populateState($ordering = 'id', $direction = 'desc')
protected function getListQuery()
{
// Initialize variables.
$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true);

// Create the base select statement.
Expand Down Expand Up @@ -184,8 +187,8 @@ public function getItems()
foreach ($items as $k => $item)
{
// Get date in local time zone
$item->created_date = JHtml::date($item->created_date, 'Y-m-d h:i:s');
$item->updated_date = JHtml::date($item->updated_date, 'Y-m-d h:i:s');
$item->created_date = HTMLHelper::date($item->created_date, 'Y-m-d h:i:s');
$item->updated_date = HTMLHelper::date($item->updated_date, 'Y-m-d h:i:s');

// Get extra date info
$items[$k]->created_day = date_format(date_create($item->created_date), "D");
Expand Down
11 changes: 7 additions & 4 deletions src/admin/models/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;

/**
* ActivityStream Model
*
* @since 0.0.1
*/
class ActivityStreamModelActivity extends JModelAdmin
class ActivityStreamModelActivity extends AdminModel
{
/**
* Method to get a table object, load it if necessary.
Expand All @@ -29,7 +32,7 @@ class ActivityStreamModelActivity extends JModelAdmin
*/
public function getTable($type = 'activity', $prefix = 'ActivityStreamTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
return Table::getInstance($type, $prefix, $config);
}

/**
Expand Down Expand Up @@ -72,7 +75,7 @@ public function getForm($data = array(), $loadData = true)
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState(
$data = Factory::getApplication()->getUserState(
'com_activitystream.edit.activity.data',
array()
);
Expand All @@ -96,7 +99,7 @@ protected function loadFormData()
*/
public function save($data)
{
$cdate = JFactory::getDate('now');
$cdate = Factory::getDate('now');

if (empty($data['id']))
{
Expand Down
12 changes: 8 additions & 4 deletions src/admin/models/fields/activitytype.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

// No direct access.
defined('_JEXEC') or die();
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;

JFormHelper::loadFieldClass('list');

Expand Down Expand Up @@ -44,8 +48,8 @@ class JFormFieldActivityType extends JFormFieldList
*/
protected function getOptions()
{
$db = JFactory::getDbo();
$client = JFactory::getApplication()->input->get('client', '', 'STRING');
$db = Factory::getDbo();
$client = Factory::getApplication()->input->get('client', '', 'STRING');
$query = $db->getQuery(true);

$query->select('distinct l.type')
Expand All @@ -57,14 +61,14 @@ protected function getOptions()
// Send filter values
$activityType = $db->loadObjectList();
$options = array();
$options[] = JHtml::_('select.option', 'all', JText::_('COM_ACTIVITYSTREAM_SEARCH_FILTER'));
$options[] = HTMLHelper::_('select.option', 'all', Text::_('COM_ACTIVITYSTREAM_SEARCH_FILTER'));

foreach ($activityType as $type)
{
$temp = implode("_", explode('.', $type->type));
$filterValue = $client . '_activity_type_' . $temp;
$filterText = strtoupper($filterValue);
$options[] = JHtml::_('select.option', $type->type, JText::_($filterText));
$options[] = HTMLHelper::_('select.option', $type->type, Text::_($filterText));
}

return $options;
Expand Down
17 changes: 10 additions & 7 deletions src/admin/tables/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
*/
// No direct access
defined('_JEXEC') or die;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;

/**
* Hello Table class
*
* @since 0.0.1
*/
class ActivityStreamTableActivity extends JTable
class ActivityStreamTableActivity extends Table
{
/**
* Constructor
Expand All @@ -34,34 +37,34 @@ public function __construct(&$db)
*/
public function check()
{
$jinput = JFactory::getApplication()->input;
$db = JFactory::getDbo();
$jinput = Factory::getApplication()->input;
$db = Factory::getDbo();
$errors = array();

// Activity type should not be empty
if (empty($this->type))
{
$errors['type'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TYPE_REQUIRED');
$errors['type'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TYPE_REQUIRED');
}

// Actor and actor_id should not be empty
if (empty($this->actor_id) || empty($this->actor))
{
$errors['actor'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_ACTOR_REQUIRED');
$errors['actor'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_ACTOR_REQUIRED');
}

// Object and object_id should not be empty
if (empty($this->object_id) || empty($this->object))
{
$errors['object'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_OBJECT_REQUIRED');
$errors['object'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_OBJECT_REQUIRED');
}

// If there is data in target then target_id should not be empty
if (!empty($this->target))
{
if (empty($this->target_id))
{
$errors['target_id'] = JText::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TARGET_REQUIRED');
$errors['target_id'] = Text::_('COM_ACTIVITYSTREAM_ACTIVITY_ERROR_TARGET_REQUIRED');
}
}

Expand Down
Loading

0 comments on commit 6cf6c53

Please sign in to comment.