From 149239fe31922e3275b313679eec1b3a072b95e3 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 04:51:32 -0600 Subject: [PATCH 01/16] Create listview This should be used to create the list of items and will let the user choose a single view item. Most likely used when the viewname ends with "s" --- view/templates/_listview.html.php | 124 ++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 view/templates/_listview.html.php diff --git a/view/templates/_listview.html.php b/view/templates/_listview.html.php new file mode 100644 index 0000000..1664020 --- /dev/null +++ b/view/templates/_listview.html.php @@ -0,0 +1,124 @@ +/view.html.php + * + * View and display logic for back-end administrator view <%= name %> in <%= componentName %> component + * + * @package <%= _.slugify(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ + +defined('_JEXEC') or die; + +/** + * Class <%= viewClassName %> + * @author <%= authorName %> <<%= authorEmail %>> + * TODO: Describe your view here + */ +class <%= viewClassName %>View<%= _.classify(componentName) %> extends JViewLegacy { + // TODO: place attributes here: ex. $protected $items; + protected $items; + protected $pagination; + protected $state; + + /** + * Display logic for when view is displayed + * + * @author <%= authorName %> <<%= authorEmail %>> + * + * @param String $tpl template which is used to display the component page (view) + * + * @return bool whether items have been displayed + */ + public function display($tpl = null) { + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + throw new Exception(implode("\n", $errors)); + } + + //<%= _.classify(componentName) %>Helper::addSubmenu("'".<%= viewClassName %>."'"); + + // TODO: constructor logic here + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @since 1.6 + */ + protected function addToolbar() { + require_once JPATH_COMPONENT . '/helpers/<%= _.classify(componentName) %>.php'; + $state = $this->get('State'); + $canDo = Metro_<%= viewFolderName.slice(0,-1) %>Helper::getActions($state->get('filter.category_id')); + JToolBarHelper::title(JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_TITLE_<%= _.classify(viewClassName).toUpperCase() %>'), '<%= viewFolderName %>.png'); + //Check if the form exists before showing the add/edit buttons + $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/<%= viewFolderName.slice(0,-1) %>'; + if (file_exists($formPath)) { + if ($canDo->get('core.create')) { + JToolBarHelper::addNew('<%= viewFolderName.slice(0,-1) %>.add', 'JTOOLBAR_NEW'); + } + if ($canDo->get('core.edit') && isset($this->items[0])) { + JToolBarHelper::editList('<%= viewFolderName.slice(0,-1) %>.edit', 'JTOOLBAR_EDIT'); + } + } + if ($canDo->get('core.edit.state')) { + if (isset($this->items[0]->state)) { + JToolBarHelper::divider(); + JToolBarHelper::custom('<%= viewFolderName %>.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); + JToolBarHelper::custom('<%= viewFolderName %>.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); + } else if (isset($this->items[0])) { + //If this component does not use state then show a direct delete button as we can not trash + JToolBarHelper::deleteList('', '<%= viewFolderName %>.delete', 'JTOOLBAR_DELETE'); + } + if (isset($this->items[0]->state)) { + JToolBarHelper::divider(); + JToolBarHelper::archiveList('<%= viewFolderName %>.archive', 'JTOOLBAR_ARCHIVE'); + } + if (isset($this->items[0]->checked_out)) { + JToolBarHelper::custom('<%= viewFolderName %>.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); + } + } + //Show trash and delete for components that uses the state field + if (isset($this->items[0]->state)) { + if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { + JToolBarHelper::deleteList('', '<%= viewFolderName %>.delete', 'JTOOLBAR_EMPTY_TRASH'); + JToolBarHelper::divider(); + } else if ($canDo->get('core.edit.state')) { + JToolBarHelper::trash('<%= viewFolderName %>.trash', 'JTOOLBAR_TRASH'); + JToolBarHelper::divider(); + } + } + if ($canDo->get('core.admin')) { + JToolBarHelper::preferences('com_<%= _.classify(componentName) %>'); + } + //Set sidebar action - New in 3.0 + JHtmlSidebar::setAction('index.php?option=com_<%= _.classify(componentName) %>&view=<%= viewFolderName %>'); + $this->extra_sidebar = ''; + + JHtmlSidebar::addFilter( + JText::_('JOPTION_SELECT_PUBLISHED'), + 'filter_published', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true) + ); + } + + protected function getSortFields() + { + return array( + 'a.id' => JText::_('JGRID_HEADING_ID'), + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.state' => JText::_('JSTATUS'), + 'a.title' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_TITLE'), + 'a.day' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_DAY'), + 'a.sessiontime' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_SESSIONTIME'), + ); + } +} From 732f8561f479096d22168fe12d2dc679e5e45857 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 04:54:28 -0600 Subject: [PATCH 02/16] options -indexes blank file to protect against directory indexing --- view/templates/index.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 view/templates/index.html diff --git a/view/templates/index.html b/view/templates/index.html new file mode 100644 index 0000000..b8028f8 --- /dev/null +++ b/view/templates/index.html @@ -0,0 +1,2 @@ + + From d1aa28dc410a077fe0c0fd8deada1ff762e6ce2f Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:19:31 -0600 Subject: [PATCH 03/16] create generic list layout for list view generic list layout for listview --- view/templates/_listdefault.php | 208 ++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 view/templates/_listdefault.php diff --git a/view/templates/_listdefault.php b/view/templates/_listdefault.php new file mode 100644 index 0000000..3203f43 --- /dev/null +++ b/view/templates/_listdefault.php @@ -0,0 +1,208 @@ +/default.php + * + * Default view for view <%= name %> in <%= componentName %> component + * + * @package <%= _.slugify(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ + // no direct access + defined('_JEXEC') or die; + //JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); + JHtml::_('bootstrap.tooltip'); + JHtml::_('behavior.multiselect'); + JHtml::_('formbehavior.chosen', 'select'); + // Import CSS + $document = JFactory::getDocument(); + $document->addStyleSheet('components/com_<%= _.underscored(componentName) %>/assets/css/<%= _.underscored(componentName) %>.css'); + $user = JFactory::getUser(); + $userId = $user->get('id'); + $listOrder = $this->state->get('list.ordering'); + $listDirn = $this->state->get('list.direction'); + $canOrder = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); + $saveOrder = $listOrder == 'a.ordering'; + if ($saveOrder) + { + $saveOrderingUrl = 'index.php?option=com_<%= _.underscored(componentName) %>&task=<%= viewFolderName %>.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', '<%= viewFolderName.slice(0,-1) %>List', 'adminForm', strtolower($listDirn), $saveOrderingUrl); + } + $sortFields = $this->getSortFields(); + ?> + + + extra_sidebar)) { + $this->sidebar .= $this->extra_sidebar; + } + ?> + +
+ sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
+ + + + items[0]->ordering)): ?> + + + + items[0]->state)): ?> + + + + + + + items[0]->id)): ?> + + + + + + items[0])){ + $colspan = count(get_object_vars($this->items[0])); + } + else{ + $colspan = 10; + } + ?> + + + + + + items as $i => $item) : + $ordering = ($listOrder == 'a.ordering'); + $canCreate = $user->authorise('core.create', 'com_<%= _.underscored(componentName) %>'); + $canEdit = $user->authorise('core.edit', 'com_<%= _.underscored(componentName) %>'); + $canCheckin = $user->authorise('core.manage', 'com_<%= _.underscored(componentName) %>'); + $canChange = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); + ?> + + + items[0]->ordering)): ?> + + + + items[0]->state)): ?> + + + + + + + items[0]->id)): ?> + + + + + +
+ ', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> + + + + + + _<%= viewFolderName.toUpperCase() %>_TITLE', 'a.title', $listDirn, $listOrder); ?> + + +
+ pagination->getListFooter(); ?> +
+ + + + + + + + + + + + id); ?> + + state, $i, '<%= viewFolderName %>.', $canChange, 'cb'); ?> + + checked_out) && $item->checked_out) : ?> + editor, $item->checked_out_time, '<%= viewFolderName %>.', $canCheckin); ?> + + + + escape($item->title); ?> + + escape($item->title); ?> + + + id; ?> +
+ + + + + + +
+ From 9f7303a12312be518a97366efd65690c2f5131bb Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:22:51 -0600 Subject: [PATCH 04/16] Create listview This should be used to create the list of items and will let the user choose a single view item. Most likely used when the viewname ends with "s" --- view/templates/_listview/_listview.html.php | 122 ++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 view/templates/_listview/_listview.html.php diff --git a/view/templates/_listview/_listview.html.php b/view/templates/_listview/_listview.html.php new file mode 100644 index 0000000..b7f56a0 --- /dev/null +++ b/view/templates/_listview/_listview.html.php @@ -0,0 +1,122 @@ +/view.html.php + * + * View and display logic for back-end administrator view <%= name %> in <%= componentName %> component + * + * @package <%= _.slugify(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ +defined('_JEXEC') or die; +/** + * Class <%= viewClassName %> + * @author <%= authorName %> <<%= authorEmail %>> + * TODO: Describe your view here + */ +class <%= viewClassName %>View<%= _.classify(componentName) %> extends JViewLegacy { + // TODO: place attributes here: ex. $protected $items; + protected $items; + protected $pagination; + protected $state; + + /** + * Display logic for when view is displayed + * + * @author <%= authorName %> <<%= authorEmail %>> + * + * @param String $tpl template which is used to display the component page (view) + * + * @return bool whether items have been displayed + */ + public function display($tpl = null) { + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + throw new Exception(implode("\n", $errors)); + } + + //<%= _.classify(componentName) %>Helper::addSubmenu("'".<%= viewClassName %>."'"); + + // TODO: constructor logic here + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @since 1.6 + */ + protected function addToolbar() { + require_once JPATH_COMPONENT . '/helpers/<%= _.classify(componentName) %>.php'; + $state = $this->get('State'); + $canDo = Metro_<%= viewFolderName.slice(0,-1) %>Helper::getActions($state->get('filter.category_id')); + JToolBarHelper::title(JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_TITLE_<%= _.classify(viewClassName).toUpperCase() %>'), '<%= viewFolderName %>.png'); + //Check if the form exists before showing the add/edit buttons + $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/<%= viewFolderName.slice(0,-1) %>'; + if (file_exists($formPath)) { + if ($canDo->get('core.create')) { + JToolBarHelper::addNew('<%= viewFolderName.slice(0,-1) %>.add', 'JTOOLBAR_NEW'); + } + if ($canDo->get('core.edit') && isset($this->items[0])) { + JToolBarHelper::editList('<%= viewFolderName.slice(0,-1) %>.edit', 'JTOOLBAR_EDIT'); + } + } + if ($canDo->get('core.edit.state')) { + if (isset($this->items[0]->state)) { + JToolBarHelper::divider(); + JToolBarHelper::custom('<%= viewFolderName %>.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); + JToolBarHelper::custom('<%= viewFolderName %>.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); + } else if (isset($this->items[0])) { + //If this component does not use state then show a direct delete button as we can not trash + JToolBarHelper::deleteList('', '<%= viewFolderName %>.delete', 'JTOOLBAR_DELETE'); + } + if (isset($this->items[0]->state)) { + JToolBarHelper::divider(); + JToolBarHelper::archiveList('<%= viewFolderName %>.archive', 'JTOOLBAR_ARCHIVE'); + } + if (isset($this->items[0]->checked_out)) { + JToolBarHelper::custom('<%= viewFolderName %>.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); + } + } + //Show trash and delete for components that uses the state field + if (isset($this->items[0]->state)) { + if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { + JToolBarHelper::deleteList('', '<%= viewFolderName %>.delete', 'JTOOLBAR_EMPTY_TRASH'); + JToolBarHelper::divider(); + } else if ($canDo->get('core.edit.state')) { + JToolBarHelper::trash('<%= viewFolderName %>.trash', 'JTOOLBAR_TRASH'); + JToolBarHelper::divider(); + } + } + if ($canDo->get('core.admin')) { + JToolBarHelper::preferences('com_<%= _.classify(componentName) %>'); + } + //Set sidebar action - New in 3.0 + JHtmlSidebar::setAction('index.php?option=com_<%= _.classify(componentName) %>&view=<%= viewFolderName %>'); + $this->extra_sidebar = ''; + + JHtmlSidebar::addFilter( + JText::_('JOPTION_SELECT_PUBLISHED'), + 'filter_published', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true) + ); + } + + protected function getSortFields() + { + return array( + 'a.id' => JText::_('JGRID_HEADING_ID'), + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.state' => JText::_('JSTATUS'), + 'a.title' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_TITLE'), + 'a.day' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_DAY'), + 'a.sessiontime' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_SESSIONTIME'), + ); + } +} From 328f091f14d64dad695c97f2cf0aaa533ab62bd5 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:24:36 -0600 Subject: [PATCH 05/16] options -indexes no indexes --- view/templates/_listview/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 view/templates/_listview/index.html diff --git a/view/templates/_listview/index.html b/view/templates/_listview/index.html new file mode 100644 index 0000000..0dc101b --- /dev/null +++ b/view/templates/_listview/index.html @@ -0,0 +1 @@ + From 08c813c51d6827745c06c9ba22e6075576066668 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:25:21 -0600 Subject: [PATCH 06/16] options -indexes no indexing --- view/templates/_listview/tmpl/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 view/templates/_listview/tmpl/index.html diff --git a/view/templates/_listview/tmpl/index.html b/view/templates/_listview/tmpl/index.html new file mode 100644 index 0000000..0dc101b --- /dev/null +++ b/view/templates/_listview/tmpl/index.html @@ -0,0 +1 @@ + From 7bdae79f752a7ba59f83e7d2883fafee73d62970 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:27:01 -0600 Subject: [PATCH 07/16] generic list layout for listview generic list layout for listview --- .../templates/_listview/tmpl/_listdefault.php | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 view/templates/_listview/tmpl/_listdefault.php diff --git a/view/templates/_listview/tmpl/_listdefault.php b/view/templates/_listview/tmpl/_listdefault.php new file mode 100644 index 0000000..3203f43 --- /dev/null +++ b/view/templates/_listview/tmpl/_listdefault.php @@ -0,0 +1,208 @@ +/default.php + * + * Default view for view <%= name %> in <%= componentName %> component + * + * @package <%= _.slugify(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ + // no direct access + defined('_JEXEC') or die; + //JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); + JHtml::_('bootstrap.tooltip'); + JHtml::_('behavior.multiselect'); + JHtml::_('formbehavior.chosen', 'select'); + // Import CSS + $document = JFactory::getDocument(); + $document->addStyleSheet('components/com_<%= _.underscored(componentName) %>/assets/css/<%= _.underscored(componentName) %>.css'); + $user = JFactory::getUser(); + $userId = $user->get('id'); + $listOrder = $this->state->get('list.ordering'); + $listDirn = $this->state->get('list.direction'); + $canOrder = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); + $saveOrder = $listOrder == 'a.ordering'; + if ($saveOrder) + { + $saveOrderingUrl = 'index.php?option=com_<%= _.underscored(componentName) %>&task=<%= viewFolderName %>.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', '<%= viewFolderName.slice(0,-1) %>List', 'adminForm', strtolower($listDirn), $saveOrderingUrl); + } + $sortFields = $this->getSortFields(); + ?> + + + extra_sidebar)) { + $this->sidebar .= $this->extra_sidebar; + } + ?> + +
+ sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
+ + + + items[0]->ordering)): ?> + + + + items[0]->state)): ?> + + + + + + + items[0]->id)): ?> + + + + + + items[0])){ + $colspan = count(get_object_vars($this->items[0])); + } + else{ + $colspan = 10; + } + ?> + + + + + + items as $i => $item) : + $ordering = ($listOrder == 'a.ordering'); + $canCreate = $user->authorise('core.create', 'com_<%= _.underscored(componentName) %>'); + $canEdit = $user->authorise('core.edit', 'com_<%= _.underscored(componentName) %>'); + $canCheckin = $user->authorise('core.manage', 'com_<%= _.underscored(componentName) %>'); + $canChange = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); + ?> + + + items[0]->ordering)): ?> + + + + items[0]->state)): ?> + + + + + + + items[0]->id)): ?> + + + + + +
+ ', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> + + + + + + _<%= viewFolderName.toUpperCase() %>_TITLE', 'a.title', $listDirn, $listOrder); ?> + + +
+ pagination->getListFooter(); ?> +
+ + + + + + + + + + + + id); ?> + + state, $i, '<%= viewFolderName %>.', $canChange, 'cb'); ?> + + checked_out) && $item->checked_out) : ?> + editor, $item->checked_out_time, '<%= viewFolderName %>.', $canCheckin); ?> + + + + escape($item->title); ?> + + escape($item->title); ?> + + + id; ?> +
+ + + + + + +
+ From d4e93c303f3accbf81d5ae97a67a5d47e97f07e6 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:28:13 -0600 Subject: [PATCH 08/16] Delete _listview.html.php --- view/templates/_listview.html.php | 124 ------------------------------ 1 file changed, 124 deletions(-) delete mode 100644 view/templates/_listview.html.php diff --git a/view/templates/_listview.html.php b/view/templates/_listview.html.php deleted file mode 100644 index 1664020..0000000 --- a/view/templates/_listview.html.php +++ /dev/null @@ -1,124 +0,0 @@ -/view.html.php - * - * View and display logic for back-end administrator view <%= name %> in <%= componentName %> component - * - * @package <%= _.slugify(componentName) %> - * @subpackage <%= viewFolderName %> - * - * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. - * @license <%= license %> - */ - -defined('_JEXEC') or die; - -/** - * Class <%= viewClassName %> - * @author <%= authorName %> <<%= authorEmail %>> - * TODO: Describe your view here - */ -class <%= viewClassName %>View<%= _.classify(componentName) %> extends JViewLegacy { - // TODO: place attributes here: ex. $protected $items; - protected $items; - protected $pagination; - protected $state; - - /** - * Display logic for when view is displayed - * - * @author <%= authorName %> <<%= authorEmail %>> - * - * @param String $tpl template which is used to display the component page (view) - * - * @return bool whether items have been displayed - */ - public function display($tpl = null) { - $this->state = $this->get('State'); - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - - // Check for errors. - if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors)); - } - - //<%= _.classify(componentName) %>Helper::addSubmenu("'".<%= viewClassName %>."'"); - - // TODO: constructor logic here - parent::display($tpl); - } - - /** - * Add the page title and toolbar. - * - * @since 1.6 - */ - protected function addToolbar() { - require_once JPATH_COMPONENT . '/helpers/<%= _.classify(componentName) %>.php'; - $state = $this->get('State'); - $canDo = Metro_<%= viewFolderName.slice(0,-1) %>Helper::getActions($state->get('filter.category_id')); - JToolBarHelper::title(JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_TITLE_<%= _.classify(viewClassName).toUpperCase() %>'), '<%= viewFolderName %>.png'); - //Check if the form exists before showing the add/edit buttons - $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/<%= viewFolderName.slice(0,-1) %>'; - if (file_exists($formPath)) { - if ($canDo->get('core.create')) { - JToolBarHelper::addNew('<%= viewFolderName.slice(0,-1) %>.add', 'JTOOLBAR_NEW'); - } - if ($canDo->get('core.edit') && isset($this->items[0])) { - JToolBarHelper::editList('<%= viewFolderName.slice(0,-1) %>.edit', 'JTOOLBAR_EDIT'); - } - } - if ($canDo->get('core.edit.state')) { - if (isset($this->items[0]->state)) { - JToolBarHelper::divider(); - JToolBarHelper::custom('<%= viewFolderName %>.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); - JToolBarHelper::custom('<%= viewFolderName %>.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); - } else if (isset($this->items[0])) { - //If this component does not use state then show a direct delete button as we can not trash - JToolBarHelper::deleteList('', '<%= viewFolderName %>.delete', 'JTOOLBAR_DELETE'); - } - if (isset($this->items[0]->state)) { - JToolBarHelper::divider(); - JToolBarHelper::archiveList('<%= viewFolderName %>.archive', 'JTOOLBAR_ARCHIVE'); - } - if (isset($this->items[0]->checked_out)) { - JToolBarHelper::custom('<%= viewFolderName %>.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); - } - } - //Show trash and delete for components that uses the state field - if (isset($this->items[0]->state)) { - if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { - JToolBarHelper::deleteList('', '<%= viewFolderName %>.delete', 'JTOOLBAR_EMPTY_TRASH'); - JToolBarHelper::divider(); - } else if ($canDo->get('core.edit.state')) { - JToolBarHelper::trash('<%= viewFolderName %>.trash', 'JTOOLBAR_TRASH'); - JToolBarHelper::divider(); - } - } - if ($canDo->get('core.admin')) { - JToolBarHelper::preferences('com_<%= _.classify(componentName) %>'); - } - //Set sidebar action - New in 3.0 - JHtmlSidebar::setAction('index.php?option=com_<%= _.classify(componentName) %>&view=<%= viewFolderName %>'); - $this->extra_sidebar = ''; - - JHtmlSidebar::addFilter( - JText::_('JOPTION_SELECT_PUBLISHED'), - 'filter_published', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true) - ); - } - - protected function getSortFields() - { - return array( - 'a.id' => JText::_('JGRID_HEADING_ID'), - 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), - 'a.state' => JText::_('JSTATUS'), - 'a.title' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_TITLE'), - 'a.day' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_DAY'), - 'a.sessiontime' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_SESSIONTIME'), - ); - } -} From d9a94b273dc86b24951b781593f8297ca56b7981 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:29:10 -0600 Subject: [PATCH 09/16] Delete _listdefault.php --- view/templates/_listdefault.php | 208 -------------------------------- 1 file changed, 208 deletions(-) delete mode 100644 view/templates/_listdefault.php diff --git a/view/templates/_listdefault.php b/view/templates/_listdefault.php deleted file mode 100644 index 3203f43..0000000 --- a/view/templates/_listdefault.php +++ /dev/null @@ -1,208 +0,0 @@ -/default.php - * - * Default view for view <%= name %> in <%= componentName %> component - * - * @package <%= _.slugify(componentName) %> - * @subpackage <%= viewFolderName %> - * - * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. - * @license <%= license %> - */ - // no direct access - defined('_JEXEC') or die; - //JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); - JHtml::_('bootstrap.tooltip'); - JHtml::_('behavior.multiselect'); - JHtml::_('formbehavior.chosen', 'select'); - // Import CSS - $document = JFactory::getDocument(); - $document->addStyleSheet('components/com_<%= _.underscored(componentName) %>/assets/css/<%= _.underscored(componentName) %>.css'); - $user = JFactory::getUser(); - $userId = $user->get('id'); - $listOrder = $this->state->get('list.ordering'); - $listDirn = $this->state->get('list.direction'); - $canOrder = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); - $saveOrder = $listOrder == 'a.ordering'; - if ($saveOrder) - { - $saveOrderingUrl = 'index.php?option=com_<%= _.underscored(componentName) %>&task=<%= viewFolderName %>.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', '<%= viewFolderName.slice(0,-1) %>List', 'adminForm', strtolower($listDirn), $saveOrderingUrl); - } - $sortFields = $this->getSortFields(); - ?> - - - extra_sidebar)) { - $this->sidebar .= $this->extra_sidebar; - } - ?> - -
- sidebar)): ?> -
- sidebar; ?> -
-
- -
- - -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
-
- - - - items[0]->ordering)): ?> - - - - items[0]->state)): ?> - - - - - - - items[0]->id)): ?> - - - - - - items[0])){ - $colspan = count(get_object_vars($this->items[0])); - } - else{ - $colspan = 10; - } - ?> - - - - - - items as $i => $item) : - $ordering = ($listOrder == 'a.ordering'); - $canCreate = $user->authorise('core.create', 'com_<%= _.underscored(componentName) %>'); - $canEdit = $user->authorise('core.edit', 'com_<%= _.underscored(componentName) %>'); - $canCheckin = $user->authorise('core.manage', 'com_<%= _.underscored(componentName) %>'); - $canChange = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); - ?> - - - items[0]->ordering)): ?> - - - - items[0]->state)): ?> - - - - - - - items[0]->id)): ?> - - - - - -
- ', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> - - - - - - _<%= viewFolderName.toUpperCase() %>_TITLE', 'a.title', $listDirn, $listOrder); ?> - - -
- pagination->getListFooter(); ?> -
- - - - - - - - - - - - id); ?> - - state, $i, '<%= viewFolderName %>.', $canChange, 'cb'); ?> - - checked_out) && $item->checked_out) : ?> - editor, $item->checked_out_time, '<%= viewFolderName %>.', $canCheckin); ?> - - - - escape($item->title); ?> - - escape($item->title); ?> - - - id; ?> -
- - - - - - -
- From ddb242bfbd6165af9d6c028c4997ba33e82cd76e Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:41:56 -0600 Subject: [PATCH 10/16] create single item view create single item view --- view/templates/_itemview/_view.html.php | 70 +++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 view/templates/_itemview/_view.html.php diff --git a/view/templates/_itemview/_view.html.php b/view/templates/_itemview/_view.html.php new file mode 100644 index 0000000..9d632e8 --- /dev/null +++ b/view/templates/_itemview/_view.html.php @@ -0,0 +1,70 @@ +/view.html.php + * + * View and display logic for back-end administrator view <%= name %> in <%= componentName %> component + * + * @package <%= _.slugify(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ + +// No direct access +defined('_JEXEC') or die; +jimport('joomla.application.component.view'); +/** + * View to edit + */ +class <%= viewClassName %>View<%= _.classify(componentName) %> extends JViewLegacy { + protected $state; + protected $item; + protected $form; + /** + * Display the view + */ + public function display($tpl = null) { + $this->state = $this->get('State'); + $this->item = $this->get('Item'); + $this->form = $this->get('Form'); + // Check for errors. + if (count($errors = $this->get('Errors'))) { + throw new Exception(implode("\n", $errors)); + } + $this->addToolbar(); + parent::display($tpl); + } + /** + * Add the page title and toolbar. + */ + protected function addToolbar() { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $isNew = ($this->item->id == 0); + if (isset($this->item->checked_out)) { + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + } else { + $checkedOut = false; + } + $canDo = <%= viewClassName %>Helper::getActions(); + JToolBarHelper::title(JText::_('COM_<%= _.underscored(componentName).toUpperCase() %>_TITLE_<%= viewFolderName.toUpperCase() %>'), '<%= viewFolderName %>.png'); + // If not checked out, can save the item. + if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) { + JToolBarHelper::apply('<%= viewFolderName %>.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('<%= viewFolderName %>.save', 'JTOOLBAR_SAVE'); + } + if (!$checkedOut && ($canDo->get('core.create'))) { + JToolBarHelper::custom('<%= viewFolderName %>.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + // If an existing item, can save to a copy. + if (!$isNew && $canDo->get('core.create')) { + JToolBarHelper::custom('<%= viewFolderName %>.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + if (empty($this->item->id)) { + JToolBarHelper::cancel('<%= viewFolderName %>.cancel', 'JTOOLBAR_CANCEL'); + } else { + JToolBarHelper::cancel('<%= viewFolderName %>.cancel', 'JTOOLBAR_CLOSE'); + } + } +} From 8589f96652020a06b33b492846686acd3d73b223 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:42:41 -0600 Subject: [PATCH 11/16] options -indexes no indexing --- view/templates/_itemview/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 view/templates/_itemview/index.html diff --git a/view/templates/_itemview/index.html b/view/templates/_itemview/index.html new file mode 100644 index 0000000..0dc101b --- /dev/null +++ b/view/templates/_itemview/index.html @@ -0,0 +1 @@ + From 3ccc594f7b8b1d79bf60f58d7a54dbe725030453 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 05:43:26 -0600 Subject: [PATCH 12/16] options -indexes no indexing --- view/templates/_itemview/tmpl/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 view/templates/_itemview/tmpl/index.html diff --git a/view/templates/_itemview/tmpl/index.html b/view/templates/_itemview/tmpl/index.html new file mode 100644 index 0000000..0dc101b --- /dev/null +++ b/view/templates/_itemview/tmpl/index.html @@ -0,0 +1 @@ + From a6164939561821d349594804579a1cb40f0d911a Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 06:03:02 -0600 Subject: [PATCH 13/16] create item form single item form --- view/templates/_itemview/tmpl/_edit.php | 98 +++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 view/templates/_itemview/tmpl/_edit.php diff --git a/view/templates/_itemview/tmpl/_edit.php b/view/templates/_itemview/tmpl/_edit.php new file mode 100644 index 0000000..8db8fdb --- /dev/null +++ b/view/templates/_itemview/tmpl/_edit.php @@ -0,0 +1,98 @@ +/edit.php + * + * Default view for view <%= name %> in <%= componentName %> component + * + * @package <%= _.underscored(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ +// no direct access +defined('_JEXEC') or die; + +JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +JHtml::_('behavior.tooltip'); +JHtml::_('behavior.formvalidation'); +JHtml::_('behavior.keepalive'); + +// Import CSS +$document = JFactory::getDocument(); +$document->addStyleSheet('components/com_<%= _.underscored(componentName) %>/assets/css/<%= _.underscored(componentName) %>.css'); +?> + +
+
+
form->getLabel('title'); ?>
+ form->getInput('title'); ?> +
+ 'general')); ?> + _TITLE_GENERAL')); ?> +
+
+
+
+
form->getLabel('id'); ?>
+
form->getInput('id'); ?>
+
+ + + + + item->created_by)){ ?> + + + + +
+
form->getLabel(''); ?>
+
form->getInput(''); ?>
+
+
+
+
+ + _TITLE_INFORMATION')); ?> +
+
+
+
form->getLabel(''); ?>
+
form->getInput(''); ?>
+
+
+
+
+
+
+
form->getLabel(''); ?>
+
form->getInput(''); ?>
+
+
+
+ + + + +
+ + From 96fcb78d92334b459acf063ea902db9f7dbb8e33 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 06:21:00 -0600 Subject: [PATCH 14/16] Rename _listdefault.php to _default.php --- view/templates/_listview/tmpl/{_listdefault.php => _default.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename view/templates/_listview/tmpl/{_listdefault.php => _default.php} (100%) diff --git a/view/templates/_listview/tmpl/_listdefault.php b/view/templates/_listview/tmpl/_default.php similarity index 100% rename from view/templates/_listview/tmpl/_listdefault.php rename to view/templates/_listview/tmpl/_default.php From c0c95a9fb6ed485ed9f892eb5260b81e9dd6e6cf Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 06:26:16 -0600 Subject: [PATCH 15/16] Update _listview.html.php --- view/templates/_listview/_listview.html.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/view/templates/_listview/_listview.html.php b/view/templates/_listview/_listview.html.php index b7f56a0..a8b889d 100644 --- a/view/templates/_listview/_listview.html.php +++ b/view/templates/_listview/_listview.html.php @@ -115,8 +115,6 @@ protected function getSortFields() 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.state' => JText::_('JSTATUS'), 'a.title' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_TITLE'), - 'a.day' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_DAY'), - 'a.sessiontime' => JText::_('COM_<%= _.slugify(componentName).toUpperCase() %>_<%= _.classify(viewClassName).toUpperCase() %>_SESSIONTIME'), ); } } From b5ce120115f6af83c3ac04da2be57cbe9c970489 Mon Sep 17 00:00:00 2001 From: Oasis Date: Tue, 25 Nov 2014 06:28:28 -0600 Subject: [PATCH 16/16] Update _default.php --- view/templates/_listview/tmpl/_default.php | 403 ++++++++++----------- 1 file changed, 196 insertions(+), 207 deletions(-) diff --git a/view/templates/_listview/tmpl/_default.php b/view/templates/_listview/tmpl/_default.php index 3203f43..03e1bc5 100644 --- a/view/templates/_listview/tmpl/_default.php +++ b/view/templates/_listview/tmpl/_default.php @@ -1,208 +1,197 @@ /default.php - * - * Default view for view <%= name %> in <%= componentName %> component - * - * @package <%= _.slugify(componentName) %> - * @subpackage <%= viewFolderName %> - * - * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. - * @license <%= license %> - */ - // no direct access - defined('_JEXEC') or die; - //JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); - JHtml::_('bootstrap.tooltip'); - JHtml::_('behavior.multiselect'); - JHtml::_('formbehavior.chosen', 'select'); - // Import CSS - $document = JFactory::getDocument(); - $document->addStyleSheet('components/com_<%= _.underscored(componentName) %>/assets/css/<%= _.underscored(componentName) %>.css'); - $user = JFactory::getUser(); - $userId = $user->get('id'); - $listOrder = $this->state->get('list.ordering'); - $listDirn = $this->state->get('list.direction'); - $canOrder = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); - $saveOrder = $listOrder == 'a.ordering'; - if ($saveOrder) - { - $saveOrderingUrl = 'index.php?option=com_<%= _.underscored(componentName) %>&task=<%= viewFolderName %>.saveOrderAjax&tmpl=component'; - JHtml::_('sortablelist.sortable', '<%= viewFolderName.slice(0,-1) %>List', 'adminForm', strtolower($listDirn), $saveOrderingUrl); - } - $sortFields = $this->getSortFields(); - ?> - - - extra_sidebar)) { - $this->sidebar .= $this->extra_sidebar; - } - ?> - -
- sidebar)): ?> -
- sidebar; ?> -
-
- -
- - -
- -
- - -
-
- - pagination->getLimitBox(); ?> -
-
- - -
-
- - -
-
-
- - - - items[0]->ordering)): ?> - - - - items[0]->state)): ?> - - - - - - - items[0]->id)): ?> - - - - - - items[0])){ - $colspan = count(get_object_vars($this->items[0])); - } - else{ - $colspan = 10; - } - ?> - - - - - - items as $i => $item) : - $ordering = ($listOrder == 'a.ordering'); - $canCreate = $user->authorise('core.create', 'com_<%= _.underscored(componentName) %>'); - $canEdit = $user->authorise('core.edit', 'com_<%= _.underscored(componentName) %>'); - $canCheckin = $user->authorise('core.manage', 'com_<%= _.underscored(componentName) %>'); - $canChange = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); - ?> - - - items[0]->ordering)): ?> - - - - items[0]->state)): ?> - - - - - - - items[0]->id)): ?> - - - - - -
- ', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> - - - - - - _<%= viewFolderName.toUpperCase() %>_TITLE', 'a.title', $listDirn, $listOrder); ?> - - -
- pagination->getListFooter(); ?> -
- - - - - - - - - - - - id); ?> - - state, $i, '<%= viewFolderName %>.', $canChange, 'cb'); ?> - - checked_out) && $item->checked_out) : ?> - editor, $item->checked_out_time, '<%= viewFolderName %>.', $canCheckin); ?> - - - - escape($item->title); ?> - - escape($item->title); ?> - - - id; ?> -
- - - - - - -
- + /** + * <%= viewFolderName %>/default.php + * + * Default view for view <%= name %> in <%= componentName %> component + * + * @package <%= _.slugify(componentName) %> + * @subpackage <%= viewFolderName %> + * + * @copyright Copyright (C) <%= currentDate %> <%= authorName %>. All rights reserved. + * @license <%= license %> + */ + // no direct access + defined('_JEXEC') or die; + //JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); + JHtml::_('bootstrap.tooltip'); + JHtml::_('behavior.multiselect'); + JHtml::_('formbehavior.chosen', 'select'); + // Import CSS + $document = JFactory::getDocument(); + $document->addStyleSheet('components/com_<%= _.underscored(componentName) %>/assets/css/<%= _.underscored(componentName) %>.css'); + $user = JFactory::getUser(); + $userId = $user->get('id'); + $listOrder = $this->state->get('list.ordering'); + $listDirn = $this->state->get('list.direction'); + $canOrder = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); + $saveOrder = $listOrder == 'a.ordering'; + if ($saveOrder) + { + $saveOrderingUrl = 'index.php?option=com_<%= _.underscored(componentName) %>&task=<%= viewFolderName %>.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', '<%= viewFolderName.slice(0,-1) %>List', 'adminForm', strtolower($listDirn), $saveOrderingUrl); + } + $sortFields = $this->getSortFields(); + ?> + +extra_sidebar)) { + $this->sidebar .= $this->extra_sidebar; + } + ?> +
+ sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
+ + + + items[0]->ordering)): ?> + + + + items[0]->state)): ?> + + + + items[0]->id)): ?> + + + + + + items[0])){ + $colspan = count(get_object_vars($this->items[0])); + } + else{ + $colspan = 10; + } + ?> + + + + + + items as $i => $item) : + $ordering = ($listOrder == 'a.ordering'); + $canCreate = $user->authorise('core.create', 'com_<%= _.underscored(componentName) %>'); + $canEdit = $user->authorise('core.edit', 'com_<%= _.underscored(componentName) %>'); + $canCheckin = $user->authorise('core.manage', 'com_<%= _.underscored(componentName) %>'); + $canChange = $user->authorise('core.edit.state', 'com_<%= _.underscored(componentName) %>'); + ?> + + items[0]->ordering)): ?> + + + + items[0]->state)): ?> + + + + items[0]->id)): ?> + + + + + +
+ ', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> + + + + + + _<%= viewFolderName.toUpperCase() %>_TITLE', 'a.title', $listDirn, $listOrder); ?> + + +
+ pagination->getListFooter(); ?> +
+ + + + + + + + + + + + id); ?> + + state, $i, '<%= viewFolderName %>.', $canChange, 'cb'); ?> + + checked_out) && $item->checked_out) : ?> + editor, $item->checked_out_time, '<%= viewFolderName %>.', $canCheckin); ?> + + + + escape($item->title); ?> + + escape($item->title); ?> + + + id; ?> +
+ + + + + +
+