From 6d6ec013685904f793f7a27a80f089129d9cc23c Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sat, 13 Apr 2019 17:31:00 -0500 Subject: [PATCH] Namespace view classes --- .../Capabilities/HtmlView.php} | 23 ++++++--- .../Consents/HtmlView.php} | 32 ++++++++---- .../Dashboard/HtmlView.php} | 26 ++++++---- .../view.xml.php => View/Export/XmlView.php} | 13 +++-- .../Request/HtmlView.php} | 50 +++++++++++-------- .../Requests/HtmlView.php} | 40 +++++++++------ 6 files changed, 116 insertions(+), 68 deletions(-) rename administrator/components/com_privacy/{views/capabilities/view.html.php => View/Capabilities/HtmlView.php} (68%) rename administrator/components/com_privacy/{views/consents/view.html.php => View/Consents/HtmlView.php} (76%) rename administrator/components/com_privacy/{views/dashboard/view.html.php => View/Dashboard/HtmlView.php} (72%) rename administrator/components/com_privacy/{views/export/view.xml.php => View/Export/XmlView.php} (76%) rename administrator/components/com_privacy/{views/request/view.html.php => View/Request/HtmlView.php} (73%) rename administrator/components/com_privacy/{views/requests/view.html.php => View/Requests/HtmlView.php} (68%) diff --git a/administrator/components/com_privacy/views/capabilities/view.html.php b/administrator/components/com_privacy/View/Capabilities/HtmlView.php similarity index 68% rename from administrator/components/com_privacy/views/capabilities/view.html.php rename to administrator/components/com_privacy/View/Capabilities/HtmlView.php index 427508dcab598..712db26d29899 100644 --- a/administrator/components/com_privacy/views/capabilities/view.html.php +++ b/administrator/components/com_privacy/View/Capabilities/HtmlView.php @@ -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 @@ -35,7 +42,7 @@ class PrivacyViewCapabilities extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -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 */ @@ -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); } @@ -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'); } } diff --git a/administrator/components/com_privacy/views/consents/view.html.php b/administrator/components/com_privacy/View/Consents/HtmlView.php similarity index 76% rename from administrator/components/com_privacy/views/consents/view.html.php rename to administrator/components/com_privacy/View/Consents/HtmlView.php index b931c811dc9af..6c66fbf39ee8a 100644 --- a/administrator/components/com_privacy/views/consents/view.html.php +++ b/administrator/components/com_privacy/View/Consents/HtmlView.php @@ -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 @@ -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 */ @@ -45,7 +55,7 @@ class PrivacyViewConsents extends JViewLegacy /** * The pagination object * - * @var JPagination + * @var Pagination * @since 3.9.0 */ protected $pagination; @@ -61,7 +71,7 @@ class PrivacyViewConsents extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -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 */ @@ -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); } @@ -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( @@ -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'); } } diff --git a/administrator/components/com_privacy/views/dashboard/view.html.php b/administrator/components/com_privacy/View/Dashboard/HtmlView.php similarity index 72% rename from administrator/components/com_privacy/views/dashboard/view.html.php rename to administrator/components/com_privacy/View/Dashboard/HtmlView.php index f9fcd32b54467..9bcaa164a9481 100644 --- a/administrator/components/com_privacy/views/dashboard/view.html.php +++ b/administrator/components/com_privacy/View/Dashboard/HtmlView.php @@ -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 @@ -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 */ @@ -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'); @@ -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); } @@ -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'); } } diff --git a/administrator/components/com_privacy/views/export/view.xml.php b/administrator/components/com_privacy/View/Export/XmlView.php similarity index 76% rename from administrator/components/com_privacy/views/export/view.xml.php rename to administrator/components/com_privacy/View/Export/XmlView.php index dcb1fe5227629..a66fc0494d1f3 100644 --- a/administrator/components/com_privacy/views/export/view.xml.php +++ b/administrator/components/com_privacy/View/Export/XmlView.php @@ -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 @@ -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. @@ -27,13 +31,12 @@ 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(); @@ -41,7 +44,7 @@ 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); } $requestId = $model->getState($model->getName() . '.request_id'); diff --git a/administrator/components/com_privacy/views/request/view.html.php b/administrator/components/com_privacy/View/Request/HtmlView.php similarity index 73% rename from administrator/components/com_privacy/views/request/view.html.php rename to administrator/components/com_privacy/View/Request/HtmlView.php index 5697a820652e7..045c1e1f3cc22 100644 --- a/administrator/components/com_privacy/views/request/view.html.php +++ b/administrator/components/com_privacy/View/Request/HtmlView.php @@ -7,14 +7,24 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Request; + defined('_JEXEC') or die; +use Joomla\CMS\Factory; +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\Toolbar\Toolbar; +use Joomla\CMS\Toolbar\ToolbarHelper; + /** * Request view class * * @since 3.9.0 */ -class PrivacyViewRequest extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The action logs for the item @@ -27,7 +37,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The form object * - * @var JForm + * @var Form * @since 3.9.0 */ protected $form; @@ -35,7 +45,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The item record * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $item; @@ -43,7 +53,7 @@ class PrivacyViewRequest extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -55,7 +65,7 @@ class PrivacyViewRequest extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -68,13 +78,13 @@ public function display($tpl = null) // Variables only required for the default layout if ($this->getLayout() === 'default') { - /** @var ActionlogsModelActionlogs $logsModel */ + /** @var \ActionlogsModelActionlogs $logsModel */ $logsModel = $this->getModel('actionlogs'); $this->actionlogs = $logsModel->getLogsForItem('com_privacy.request', $this->item->id); // Load the com_actionlogs language strings for use in the layout - $lang = JFactory::getLanguage(); + $lang = Factory::getLanguage(); $lang->load('com_actionlogs', JPATH_ADMINISTRATOR, null, false, true) || $lang->load('com_actionlogs', JPATH_ADMINISTRATOR . '/components/com_actionlogs', null, false, true); } @@ -88,7 +98,7 @@ 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(); @@ -105,22 +115,22 @@ public function display($tpl = null) */ protected function addToolbar() { - JFactory::getApplication('administrator')->set('hidemainmenu', true); + Factory::getApplication('administrator')->set('hidemainmenu', true); // Set the title and toolbar based on the layout if ($this->getLayout() === 'edit') { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_REQUEST_ADD_REQUEST'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUEST_ADD_REQUEST'), 'lock'); - JToolbarHelper::apply('request.save'); - JToolbarHelper::cancel('request.cancel'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST_EDIT'); + ToolbarHelper::apply('request.save'); + ToolbarHelper::cancel('request.cancel'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST_EDIT'); } else { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_REQUEST_SHOW_REQUEST'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUEST_SHOW_REQUEST'), 'lock'); - $bar = JToolbar::getInstance('toolbar'); + $bar = Toolbar::getInstance('toolbar'); // Add transition and action buttons based on item status switch ($this->item->status) @@ -138,15 +148,15 @@ protected function addToolbar() if ($this->item->request_type === 'export') { - JToolbarHelper::link( + ToolbarHelper::link( JRoute::_('index.php?option=com_privacy&task=request.export&format=xml&id=' . (int) $this->item->id . $return), 'COM_PRIVACY_ACTION_EXPORT_DATA', 'download' ); - if (JFactory::getConfig()->get('mailonline', 1)) + if (Factory::getConfig()->get('mailonline', 1)) { - JToolbarHelper::link( + ToolbarHelper::link( JRoute::_('index.php?option=com_privacy&task=request.emailexport&id=' . (int) $this->item->id . $return), 'COM_PRIVACY_ACTION_EMAIL_EXPORT_DATA', 'mail' @@ -166,8 +176,8 @@ protected function addToolbar() break; } - JToolbarHelper::cancel('request.cancel', 'JTOOLBAR_CLOSE'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST'); + ToolbarHelper::cancel('request.cancel', 'JTOOLBAR_CLOSE'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUEST'); } } } diff --git a/administrator/components/com_privacy/views/requests/view.html.php b/administrator/components/com_privacy/View/Requests/HtmlView.php similarity index 68% rename from administrator/components/com_privacy/views/requests/view.html.php rename to administrator/components/com_privacy/View/Requests/HtmlView.php index ec94a3f771d07..bfc2ce57e7a61 100644 --- a/administrator/components/com_privacy/views/requests/view.html.php +++ b/administrator/components/com_privacy/View/Requests/HtmlView.php @@ -7,14 +7,25 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt */ +namespace Joomla\Component\Privacy\Administrator\View\Requests; + defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Factory; +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\ToolbarHelper; + /** * Requests view class * * @since 3.9.0 */ -class PrivacyViewRequests extends JViewLegacy +class HtmlView extends BaseHtmlView { /** * The active search tools filters @@ -28,7 +39,7 @@ class PrivacyViewRequests 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 */ @@ -45,7 +56,7 @@ class PrivacyViewRequests extends JViewLegacy /** * The pagination object * - * @var JPagination + * @var Pagination * @since 3.9.0 */ protected $pagination; @@ -69,7 +80,7 @@ class PrivacyViewRequests extends JViewLegacy /** * The state information * - * @var JObject + * @var CMSObject * @since 3.9.0 */ protected $state; @@ -89,7 +100,7 @@ class PrivacyViewRequests extends JViewLegacy * * @return mixed A string if successful, otherwise an Error object. * - * @see JViewLegacy::loadTemplate() + * @see BaseHtmlView::loadTemplate() * @since 3.9.0 * @throws Exception */ @@ -101,18 +112,18 @@ public function display($tpl = null) $this->state = $this->get('State'); $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); - $this->urgentRequestAge = (int) JComponentHelper::getParams('com_privacy')->get('notify', 14); - $this->sendMailEnabled = (bool) JFactory::getConfig()->get('mailonline', 1); + $this->urgentRequestAge = (int) ComponentHelper::getParams('com_privacy')->get('notify', 14); + $this->sendMailEnabled = (bool) Factory::getConfig()->get('mailonline', 1); // 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); } @@ -126,16 +137,15 @@ public function display($tpl = null) */ protected function addToolbar() { - JToolbarHelper::title(JText::_('COM_PRIVACY_VIEW_REQUESTS'), 'lock'); + ToolbarHelper::title(Text::_('COM_PRIVACY_VIEW_REQUESTS'), 'lock'); // Requests can only be created if mail sending is enabled - if (JFactory::getConfig()->get('mailonline', 1)) + if (Factory::getConfig()->get('mailonline', 1)) { - JToolbarHelper::addNew('request.add'); + ToolbarHelper::addNew('request.add'); } - JToolbarHelper::preferences('com_privacy'); - JToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUESTS'); - + ToolbarHelper::preferences('com_privacy'); + ToolbarHelper::help('JHELP_COMPONENTS_PRIVACY_REQUESTS'); } }