Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task #167789 chore: Added joomla 4 support code #49

Open
wants to merge 2 commits into
base: j4x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/admin/activitystream.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

// No direct access to this file
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Controller\BaseController;

// 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
14 changes: 8 additions & 6 deletions src/admin/controller.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

// 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 +19,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
40 changes: 25 additions & 15 deletions src/admin/controllers/activities.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
<?php
/**
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

// No direct access to this file
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Table\Table;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Language\Text;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\MVC\Controller\AdminController;

/**
* Activity Stream Controller
*
* @since 0.0.1
*/
class ActivityStreamControllerActivities extends JControllerAdmin
class ActivityStreamControllerActivities extends AdminController
{
/**
* Proxy for getModel.
Expand Down Expand Up @@ -44,7 +54,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 +64,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 +100,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 +123,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 +143,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 +152,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
15 changes: 9 additions & 6 deletions src/admin/controllers/activity.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

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

/**
* HelloWorld Controller
Expand All @@ -16,6 +19,6 @@
* @subpackage com_activitystream
* @since 0.0.9
*/
class ActivityStreamControllerActivity extends JControllerForm
class ActivityStreamControllerActivity extends FormController
{
}
14 changes: 8 additions & 6 deletions src/admin/helpers/activities.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
/**
* @version SVN: <svn_id>
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

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

/**
* Products helper for quick2cart backend.
Expand Down Expand Up @@ -87,7 +89,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
25 changes: 16 additions & 9 deletions src/admin/models/activities.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<?php
/**
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

// No direct access to this file
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\MVC\Model\ListModel;

/**
* ActivityStreamList Model
*
* @since 0.0.1
*/
class ActivityStreamModelActivities extends JModelList
class ActivityStreamModelActivities extends ListModel
{
/**
* Constructor.
Expand Down Expand Up @@ -60,7 +67,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 +101,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 +191,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
22 changes: 14 additions & 8 deletions src/admin/models/activity.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<?php
/**
* @package ActivityStream
* @author Techjoomla <[email protected]>
* @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved.
* @license GNU General Public License version 2 or later.
* @package Activitystream
* @subpackage Com_Activitystream
*
* @author Techjoomla <[email protected]>
* @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

// No direct access to this file
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\MVC\Model\AdminModel;

/**
* 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 +35,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 +78,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 +102,7 @@ protected function loadFormData()
*/
public function save($data)
{
$cdate = JFactory::getDate('now');
$cdate = Factory::getDate('now');

if (empty($data['id']))
{
Expand Down
Loading