Skip to content

Commit

Permalink
[4.0] Workflow namespace 2 (#21484)
Browse files Browse the repository at this point in the history
* jroute

* Jsession

* jfactory

* Jlayouthelper

* jtext
  • Loading branch information
brianteeman authored and wilsonge committed Aug 9, 2018
1 parent a937d02 commit 869247d
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu
{
parent::__construct($config, $factory, $app, $input);

// Guess the \JText message prefix. Defaults to the option.
// Guess the Text message prefix. Defaults to the option.
if (empty($this->extension))
{
$this->extension = $this->input->get('extension', 'com_content');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;

/**
* The first example class, this is in the same
Expand Down Expand Up @@ -69,7 +71,7 @@ public function getModel($name = 'State', $prefix = 'Administrator', $config = a
public function setDefault()
{
// Check for request forgeries
\JSession::checkToken('request') or die(Text::_('JINVALID_TOKEN'));
Session::checkToken('request') or die(Text::_('JINVALID_TOKEN'));

// Get items to publish from the request.
$cid = $this->input->get('cid', array(), 'array');
Expand All @@ -81,7 +83,7 @@ public function setDefault()
{
$this->setMessage(Text::_('COM_WORKFLOW_DISABLE_DEFAULT'), 'warning');
$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension"), false
)
Expand Down Expand Up @@ -118,7 +120,7 @@ public function setDefault()
}

$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension")
. '&workflow_id=' . $this->input->getCmd("workflow_id"), false
Expand All @@ -137,7 +139,7 @@ public function delete()
{
parent::delete();
$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension")
. '&workflow_id=' . $this->input->getCmd("workflow_id"), false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Router\Route;

/**
* The first example class, this is in the same
Expand Down Expand Up @@ -48,7 +49,7 @@ public function delete()
{
parent::delete();
$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension")
. '&workflow_id=' . $this->input->getCmd("workflow_id"), false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Utilities\ArrayHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;

/**
* The first example class, this is in the same
Expand Down Expand Up @@ -68,7 +70,7 @@ public function getModel($name = 'Workflow', $prefix = 'Administrator', $config
public function setDefault()
{
// Check for request forgeries
\JSession::checkToken('request') or die(Text::_('JINVALID_TOKEN'));
Session::checkToken('request') or die(Text::_('JINVALID_TOKEN'));

// Get items to publish from the request.
$cid = $this->input->get('cid', array(), 'array');
Expand All @@ -80,7 +82,7 @@ public function setDefault()
{
$this->setMessage(Text::_('COM_WORKFLOW_DISABLE_DEFAULT'), 'warning');
$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension"), false
)
Expand Down Expand Up @@ -126,7 +128,7 @@ public function setDefault()
}

$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension"), false
)
Expand All @@ -144,7 +146,7 @@ public function delete()
{
parent::delete();
$this->setRedirect(
\JRoute::_(
Route::_(
'index.php?option=' . $this->option . '&view=' . $this->view_list
. '&extension=' . $this->input->getCmd("extension"), false
)
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_workflow/Model/StateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function generateNewTitle($category_id, $alias, $title)
public function save($data)
{
$context = $this->option . '.' . $this->name;
$app = \JFactory::getApplication();
$app = Factory::getApplication();
$input = $app->input;
$workflowID = $app->getUserStateFromRequest($context . '.filter.workflow_id', 'workflow_id', 0, 'int');

Expand Down Expand Up @@ -237,7 +237,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_workflow.edit.state.data',
array()
);
Expand Down
3 changes: 2 additions & 1 deletion administrator/components/com_workflow/Model/StatesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
defined('_JEXEC') or die;

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

/**
* Model class for items
Expand Down Expand Up @@ -64,7 +65,7 @@ public function __construct($config = array())
*/
protected function populateState($ordering = 's.ordering', $direction = 'ASC')
{
$app = \JFactory::getApplication();
$app = Factory::getApplication();

$workflowID = $app->getUserStateFromRequest($this->context . '.filter.workflow_id', 'workflow_id', 1, 'int');
$extension = $app->getUserStateFromRequest($this->context . '.filter.extension', 'extension', 'com_content', 'cmd');
Expand Down
8 changes: 4 additions & 4 deletions administrator/components/com_workflow/Model/WorkflowModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function populateState()
{
parent::populateState();

$app = \JFactory::getApplication();
$app = Factory::getApplication();
$context = $this->option . '.' . $this->name;
$extension = $app->getUserStateFromRequest($context . '.filter.extension', 'extension', 'com_content', 'cmd');

Expand Down Expand Up @@ -83,8 +83,8 @@ protected function generateNewTitle($category_id, $alias, $title)
*/
public function save($data)
{
$user = \JFactory::getUser();
$app = \JFactory::getApplication();
$user = Factory::getUser();
$app = Factory::getApplication();
$input = $app->input;
$context = $this->option . '.' . $this->name;
$extension = $app->getUserStateFromRequest($context . '.filter.extension', 'extension', 'com_content', 'cmd');
Expand Down Expand Up @@ -196,7 +196,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_workflow.edit.workflow.data',
array()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
defined('_JEXEC') or die;

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

/**
* Model class for items
Expand Down Expand Up @@ -66,7 +67,7 @@ public function __construct($config = array())
*/
protected function populateState($ordering = 'w.ordering', $direction = 'asc')
{
$app = \JFactory::getApplication();
$app = Factory::getApplication();
$extension = $app->getUserStateFromRequest($this->context . '.filter.extension', 'extension', 'com_content', 'cmd');

$this->setState('filter.extension', $extension);
Expand Down
8 changes: 4 additions & 4 deletions administrator/components/com_workflow/Table/StateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function __construct(\JDatabaseDriver $db)
public function delete($pk = null)
{
// @TODO: correct ACL check should be done in $model->canDelete(...) not here
if (!\JFactory::getUser()->authorise('core.delete', 'com_workflows'))
if (!Factory::getUser()->authorise('core.delete', 'com_workflows'))
{
throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 403);
}

$db = $this->getDbo();
$app = \JFactory::getApplication();
$app = Factory::getApplication();

// Gets the update site names.
$query = $db->getQuery(true)
Expand All @@ -68,7 +68,7 @@ public function delete($pk = null)

if ($state->default)
{
$app->enqueueMessage(\JText::sprintf('COM_WORKFLOW_MSG_DELETE_DEFAULT', $state->title), 'error');
$app->enqueueMessage(Text::sprintf('COM_WORKFLOW_MSG_DELETE_DEFAULT', $state->title), 'error');

return false;
}
Expand All @@ -87,7 +87,7 @@ public function delete($pk = null)
}
catch (\RuntimeException $e)
{
$app->enqueueMessage(\JText::sprintf('COM_WORKFLOW_MSG_WORKFLOWS_DELETE_ERROR', $state->title, $e->getMessage()), 'error');
$app->enqueueMessage(Text::sprintf('COM_WORKFLOW_MSG_WORKFLOWS_DELETE_ERROR', $state->title, $e->getMessage()), 'error');
}

return false;
Expand Down
8 changes: 4 additions & 4 deletions administrator/components/com_workflow/Table/WorkflowTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function __construct(\JDatabaseDriver $db)
*/
public function delete($pk = null)
{
if (!\JFactory::getUser()->authorise('core.delete', 'com_installer'))
if (!Factory::getUser()->authorise('core.delete', 'com_installer'))
{
throw new \Exception(Text::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 403);
}

$db = $this->getDbo();
$app = \JFactory::getApplication();
$app = Factory::getApplication();

// Gets the update site names.
$query = $db->getQuery(true)
Expand All @@ -68,7 +68,7 @@ public function delete($pk = null)

if ($workflow->default)
{
$app->enqueueMessage(\JText::sprintf('COM_WORKFLOW_MSG_DELETE_DEFAULT', $workflow->title), 'error');
$app->enqueueMessage(Text::sprintf('COM_WORKFLOW_MSG_DELETE_DEFAULT', $workflow->title), 'error');

return false;
}
Expand All @@ -92,7 +92,7 @@ public function delete($pk = null)
}
catch (\RuntimeException $e)
{
$app->enqueueMessage(\JText::sprintf('COM_WORKFLOW_MSG_WORKFLOWS_DELETE_ERROR', $workflow->title, $e->getMessage()), 'error');
$app->enqueueMessage(Text::sprintf('COM_WORKFLOW_MSG_WORKFLOWS_DELETE_ERROR', $workflow->title, $e->getMessage()), 'error');

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function addToolbar()

$workflow = !empty($this->state->get('active_workflow', '')) ? $this->state->get('active_workflow', '') . ': ' : '';

ToolbarHelper::title(\JText::sprintf('COM_WORKFLOW_STATES_LIST', $this->escape($workflow)), 'address contact');
ToolbarHelper::title(Text::sprintf('COM_WORKFLOW_STATES_LIST', $this->escape($workflow)), 'address contact');

if ($canDo->get('core.create'))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function addToolbar()

$workflow = !empty($this->state->get('active_workflow', '')) ? $this->state->get('active_workflow', '') . ': ' : '';

ToolbarHelper::title(\JText::sprintf('COM_WORKFLOW_TRANSITIONS_LIST', $this->escape($workflow)), 'address contact');
ToolbarHelper::title(Text::sprintf('COM_WORKFLOW_TRANSITIONS_LIST', $this->escape($workflow)), 'address contact');

if ($canDo->get('core.create'))
{
Expand Down
9 changes: 6 additions & 3 deletions administrator/components/com_workflow/tmpl/state/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;

HTMLHelper::_('behavior.formvalidator');
HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('formbehavior.chosen', '.advancedSelect', null, array('disable_search_threshold' => 0));

$app = JFactory::getApplication();
$app = Factory::getApplication();
$input = $app->input;

// In case of modal
Expand All @@ -25,9 +28,9 @@
$tmpl = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
?>

<form action="<?php echo JRoute::_('index.php?option=com_workflow&view=state&workflow_id=' . $input->getCmd('workflow_id') . '&extension=' . $input->getCmd('extension') . '&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="workflow-form" class="form-validate">
<form action="<?php echo Route::_('index.php?option=com_workflow&view=state&workflow_id=' . $input->getCmd('workflow_id') . '&extension=' . $input->getCmd('extension') . '&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="workflow-form" class="form-validate">

<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>

<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', array('active' => 'details')); ?>

Expand Down
14 changes: 9 additions & 5 deletions administrator/components/com_workflow/tmpl/states/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;

HTMLHelper::_('behavior.tooltip');

$user = JFactory::getUser();
$user = Factory::getUser();
$userId = $user->id;

$listOrder = $this->escape($this->state->get('list.ordering'));
Expand All @@ -27,11 +31,11 @@

if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_workflow&task=states.saveOrderAjax&' . JSession::getFormToken() . '=1';
$saveOrderingUrl = 'index.php?option=com_workflow&task=states.saveOrderAjax&' . Session::getFormToken() . '=1';
HTMLHelper::_('draggablelist.draggable');
}
?>
<form action="<?php echo JRoute::_('index.php?option=com_workflow&view=states&workflow_id=' . (int) $this->workflowID . '&extension=' . $this->extension); ?>" method="post" name="adminForm" id="adminForm">
<form action="<?php echo Route::_('index.php?option=com_workflow&view=states&workflow_id=' . (int) $this->workflowID . '&extension=' . $this->extension); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<div id="j-sidebar-container" class="col-md-2">
<?php echo $this->sidebar; ?>
Expand All @@ -40,7 +44,7 @@
<div id="j-main-container" class="j-main-container">
<?php
// Search tools bar
echo \JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this));
?>
<?php if (empty($this->states)) : ?>
<div class="alert alert-warning alert-no-items">
Expand Down Expand Up @@ -75,7 +79,7 @@
</thead>
<tbody class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>">
<?php foreach ($this->states as $i => $item):
$edit = JRoute::_('index.php?option=com_workflow&task=state.edit&id=' . $item->id . '&workflow_id=' . (int) $this->workflowID . '&extension=' . $this->extension);
$edit = Route::_('index.php?option=com_workflow&task=state.edit&id=' . $item->id . '&workflow_id=' . (int) $this->workflowID . '&extension=' . $this->extension);

$canEdit = $user->authorise('core.edit', $this->extension . '.state.' . $item->id);
// @TODO set proper checkin fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Layout\LayoutHelper;

HTMLHelper::_('behavior.formvalidator');
HTMLHelper::_('behavior.keepalive');
Expand All @@ -23,9 +25,9 @@

?>

<form action="<?php echo JRoute::_('index.php?option=com_workflow&view=transition&workflow_id=' . $this->workflowID . '&extension=' . $this->input->getCmd('extension') . '&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="workflow-form" class="form-validate">
<form action="<?php echo Route::_('index.php?option=com_workflow&view=transition&workflow_id=' . $this->workflowID . '&extension=' . $this->input->getCmd('extension') . '&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="workflow-form" class="form-validate">

<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
<?php echo LayoutHelper::render('joomla.edit.title_alias', $this); ?>

<div>
<?php echo HTMLHelper::_('uitab.startTabSet', 'myTab', array('active' => 'details')); ?>
Expand Down
Loading

0 comments on commit 869247d

Please sign in to comment.