Skip to content

Commit

Permalink
Namespace view classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Babker committed Apr 14, 2019
1 parent 1dce7a0 commit 6d6ec01
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 68 deletions.
Expand Up @@ -7,14 +7,21 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Privacy\Administrator\View\Capabilities;

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Toolbar\ToolbarHelper;

/**
* Capabilities view class
*
* @since 3.9.0
*/
class PrivacyViewCapabilities extends JViewLegacy
class HtmlView extends BaseHtmlView
{
/**
* The reported extension capabilities
Expand All @@ -35,7 +42,7 @@ class PrivacyViewCapabilities extends JViewLegacy
/**
* The state information
*
* @var JObject
* @var CMSObject
* @since 3.9.0
*/
protected $state;
Expand All @@ -47,7 +54,7 @@ class PrivacyViewCapabilities extends JViewLegacy
*
* @return mixed A string if successful, otherwise an Error object.
*
* @see JViewLegacy::loadTemplate()
* @see BaseHtmlView::loadTemplate()
* @since 3.9.0
* @throws Exception
*/
Expand All @@ -60,12 +67,12 @@ public function display($tpl = null)
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
throw new \JViewGenericdataexception(implode("\n", $errors), 500);
}

$this->addToolbar();

$this->sidebar = JHtmlSidebar::render();
$this->sidebar = \JHtmlSidebar::render();

return parent::display($tpl);
}
Expand All @@ -79,10 +86,10 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_CAPABILITIES'), 'lock');
ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_CAPABILITIES'), 'lock');

JToolbarHelper::preferences('com_privacy');
ToolbarHelper::preferences('com_privacy');

JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CAPABILITIES');
ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CAPABILITIES');
}
}
Expand Up @@ -7,14 +7,24 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Privacy\Administrator\View\Consents;

defined('_JEXEC') or die;

use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;

/**
* Consents view class
*
* @since 3.9.0
*/
class PrivacyViewConsents extends JViewLegacy
class HtmlView extends BaseHtmlView
{
/**
* The active search tools filters
Expand All @@ -28,7 +38,7 @@ class PrivacyViewConsents extends JViewLegacy
/**
* Form instance containing the search tools filter form
*
* @var JForm
* @var Form
* @since 3.9.0
* @note Must be public to be accessed from the search tools layout
*/
Expand All @@ -45,7 +55,7 @@ class PrivacyViewConsents extends JViewLegacy
/**
* The pagination object
*
* @var JPagination
* @var Pagination
* @since 3.9.0
*/
protected $pagination;
Expand All @@ -61,7 +71,7 @@ class PrivacyViewConsents extends JViewLegacy
/**
* The state information
*
* @var JObject
* @var CMSObject
* @since 3.9.0
*/
protected $state;
Expand All @@ -73,7 +83,7 @@ class PrivacyViewConsents extends JViewLegacy
*
* @return mixed A string if successful, otherwise an Error object.
*
* @see JViewLegacy::loadTemplate()
* @see BaseHtmlView::loadTemplate()
* @since 3.9.0
* @throws Exception
*/
Expand All @@ -89,12 +99,12 @@ public function display($tpl = null)
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
throw new \JViewGenericdataexception(implode("\n", $errors), 500);
}

$this->addToolbar();

$this->sidebar = JHtmlSidebar::render();
$this->sidebar = \JHtmlSidebar::render();

return parent::display($tpl);
}
Expand All @@ -108,9 +118,9 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_CONSENTS'), 'lock');
ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_CONSENTS'), 'lock');

$bar = JToolbar::getInstance('toolbar');
$bar = Toolbar::getInstance('toolbar');

// Add a button to invalidate a consent
$bar->appendButton(
Expand All @@ -135,8 +145,8 @@ protected function addToolbar()
);
}

JToolbarHelper::preferences('com_privacy');
ToolbarHelper::preferences('com_privacy');

JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CONSENTS');
ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_CONSENTS');
}
}
Expand Up @@ -7,14 +7,22 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Privacy\Administrator\View\Dashboard;

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\ToolbarHelper;

/**
* Dashboard view class
*
* @since 3.9.0
*/
class PrivacyViewDashboard extends JViewLegacy
class HtmlView extends BaseHtmlView
{
/**
* Number of urgent requests based on the component configuration
Expand Down Expand Up @@ -71,7 +79,7 @@ class PrivacyViewDashboard extends JViewLegacy
*
* @return mixed A string if successful, otherwise an Error object.
*
* @see JViewLegacy::loadTemplate()
* @see BaseHtmlView::loadTemplate()
* @since 3.9.0
* @throws Exception
*/
Expand All @@ -81,7 +89,7 @@ public function display($tpl = null)
$this->privacyPolicyInfo = $this->get('PrivacyPolicyInfo');
$this->requestCounts = $this->get('RequestCounts');
$this->requestFormPublished = $this->get('RequestFormPublished');
$this->sendMailEnabled = (bool) JFactory::getConfig()->get('mailonline', 1);
$this->sendMailEnabled = (bool) Factory::getConfig()->get('mailonline', 1);

/** @var PrivacyModelRequests $requestsModel */
$requestsModel = $this->getModel('requests');
Expand All @@ -91,14 +99,14 @@ public function display($tpl = null)
// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
throw new \JViewGenericdataexception(implode("\n", $errors), 500);
}

$this->urgentRequestDays = (int) JComponentHelper::getParams('com_privacy')->get('notify', 14);
$this->urgentRequestDays = (int) ComponentHelper::getParams('com_privacy')->get('notify', 14);

$this->addToolbar();

$this->sidebar = JHtmlSidebar::render();
$this->sidebar = \JHtmlSidebar::render();

return parent::display($tpl);
}
Expand All @@ -112,10 +120,10 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_DASHBOARD'), 'lock');
ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_DASHBOARD'), 'lock');

JToolbarHelper::preferences('com_privacy');
ToolbarHelper::preferences('com_privacy');

JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_DASHBOARD');
ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_DASHBOARD');
}
}
Expand Up @@ -7,9 +7,13 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Privacy\Administrator\View\Export;

defined('_JEXEC') or die;

JLoader::register('PrivacyHelper', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/privacy.php');
use Joomla\CMS\MVC\View\AbstractView;
use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper;
use Joomla\Component\Privacy\Administrator\Model\ExportModel;

/**
* Export view class
Expand All @@ -18,7 +22,7 @@
*
* @property-read \Joomla\CMS\Document\XmlDocument $document
*/
class PrivacyViewExport extends JViewLegacy
class XmlView extends AbstractView
{
/**
* Execute and display a template script.
Expand All @@ -27,21 +31,20 @@ class PrivacyViewExport extends JViewLegacy
*
* @return mixed A string if successful, otherwise an Error object.
*
* @see JViewLegacy::loadTemplate()
* @since 3.9.0
* @throws Exception
*/
public function display($tpl = null)
{
/** @var PrivacyModelExport $model */
/** @var ExportModel $model */
$model = $this->getModel();

$exportData = $model->collectDataForExportRequest();

// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new Exception(implode("\n", $errors), 500);
throw new \JViewGenericdataexception(implode("\n", $errors), 500);
}

$requestId = $model->getState($model->getName() . '.request_id');
Expand Down

0 comments on commit 6d6ec01

Please sign in to comment.