diff --git a/admin/models/fields/preachers.php b/admin/models/fields/preachers.php index 58fa7b79..d72d72f1 100644 --- a/admin/models/fields/preachers.php +++ b/admin/models/fields/preachers.php @@ -1,4 +1,4 @@ - + @author Llewellyn van der Merwe @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - A sermon distributor that links to Dropbox. - + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + A sermon distributor that links to Dropbox. + /----------------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file @@ -48,23 +48,25 @@ class JFormFieldPreachers extends JFormFieldList */ protected function getOptions() { - $db = JFactory::getDBO(); - $query = $db->getQuery(true); - $query->select($db->quoteName(array('a.id','a.name'),array('id','preacher_request_id_name'))); - $query->from($db->quoteName('#__sermondistributor_preacher', 'a')); - $query->where($db->quoteName('a.published') . ' = 1'); - $query->order('a.name ASC'); - $db->setQuery((string)$query); - $items = $db->loadObjectList(); - $options = array(); - if ($items) - { - $options[] = JHtml::_('select.option', '', 'Select a preacher'); - foreach($items as $item) - { - $options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name); - } - } + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','preacher_request_id_name'))); + $query->from($db->quoteName('#__sermondistributor_preacher', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) { + $options[] = JHtml::_('select.option', '', 'Select a preacher'); + } + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name); + } + } return $options; } } diff --git a/admin/models/forms/filter_sermons.xml b/admin/models/forms/filter_sermons.xml new file mode 100644 index 00000000..036f2455 --- /dev/null +++ b/admin/models/forms/filter_sermons.xml @@ -0,0 +1,150 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/admin/models/sermons.php b/admin/models/sermons.php index ddd509bc..6a656312 100644 --- a/admin/models/sermons.php +++ b/admin/models/sermons.php @@ -1,81 +1,82 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - A sermon distributor that links to Dropbox. - -/----------------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -use Joomla\Utilities\ArrayHelper; - -/** - * Sermons Model - */ -class SermondistributorModelSermons extends JModelList -{ - public function __construct($config = array()) - { - if (empty($config['filter_fields'])) - { - $config['filter_fields'] = array( +/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + ____ ____ __ __ __ +/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ +\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ + \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ + /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ + \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ + \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ + +/------------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.0.x + @created 22nd October, 2015 + @package Sermon Distributor + @subpackage sermons.php + @author Llewellyn van der Merwe + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + A sermon distributor that links to Dropbox. + +/----------------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\Utilities\ArrayHelper; + +/** + * Sermons Model + */ +class SermondistributorModelSermons extends JModelList +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( 'a.id','id', 'a.published','published', 'a.ordering','ordering', 'a.created_by','created_by', 'a.modified_by','modified_by', + 'a.access','access', 'a.name','name', - 'g.name', - 'h.name', + 'g.name','preacher', + 'h.name','series', 'a.short_description','short_description', 'c.title','category_title', 'c.id', 'category_id', 'a.catid', 'catid', 'a.link_type','link_type', - 'a.source','source' - ); - } - - parent::__construct($config); - } - - /** - * Method to auto-populate the model state. - * - * @return void - */ - protected function populateState($ordering = null, $direction = null) - { - $app = JFactory::getApplication(); - - // Adjust the context to support modal layouts. - if ($layout = $app->input->get('layout')) - { - $this->context .= '.' . $layout; - } + 'a.source','source' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * @return void + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); $this->setState('filter.name', $name); - $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher'); - $this->setState('filter.preacher', $preacher); +// $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher'); +// $this->setState('filter.preacher', $preacher); $series = $this->getUserStateFromRequest($this->context . '.filter.series', 'filter_series'); $this->setState('filter.series', $series); @@ -86,8 +87,8 @@ class SermondistributorModelSermons extends JModelList $category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category'); $this->setState('filter.category', $category); - $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); - $this->setState('filter.category_id', $categoryId); +// $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); +// $this->setState('filter.category_id', $categoryId); $catid = $app->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid'); $this->setState('filter.catid', $catid); @@ -96,41 +97,58 @@ class SermondistributorModelSermons extends JModelList $this->setState('filter.link_type', $link_type); $source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source'); - $this->setState('filter.source', $source); - - $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); - $this->setState('filter.sorting', $sorting); - - $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); - $this->setState('filter.access', $access); - - $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); - $this->setState('filter.search', $search); - - $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); - $this->setState('filter.published', $published); - - $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); - $this->setState('filter.created_by', $created_by); - - $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); - $this->setState('filter.created', $created); - - // List state information. - parent::populateState($ordering, $direction); - } - - /** - * Method to get an array of data items. - * - * @return mixed An array of data items on success, false on failure. - */ - public function getItems() + $this->setState('filter.source', $source); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + $this->setState('filter.access', $access); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + // Handle multiple fields -> original code commented above + $formSubmited = $app->input->post->get('form_submited'); + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); + $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); + $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + + $categoryId = $app->input->post->get('category_id'); + $this->setState('filter.category_id', $categoryId); + + $preacher = $app->input->post->get('preacher'); + $this->setState('filter.preacher', $preacher); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() { // check in items $this->checkInNow(); - - // load parent items + + // load parent items $items = parent::getItems(); // Set values to display correctly. @@ -165,10 +183,10 @@ class SermondistributorModelSermons extends JModelList $item->source = $this->selectionTranslation($item->source, 'source'); } } - - - // return items - return $items; + + + // return items + return $items; } /** @@ -207,15 +225,15 @@ class SermondistributorModelSermons extends JModelList } } return $value; - } - - /** - * Method to build an SQL query to load the list data. - * - * @return string An SQL query - */ - protected function getListQuery() - { + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { // Get the user object. $user = JFactory::getUser(); // Create a new query object. @@ -253,10 +271,19 @@ class SermondistributorModelSermons extends JModelList $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Filter by access level. - if ($access = $this->getState('filter.access')) + $access = $this->getState('filter.access'); + + if (is_numeric($access)) { $query->where('a.access = ' . (int) $access); } + elseif (is_array($access)) + { + $access = ArrayHelper::toInteger($access); + $access = implode(',', $access); + $query->where('a.access IN (' . $access . ')'); + } + // Implement View Level Access if (!$user->authorise('core.options', 'com_sermondistributor')) { @@ -279,9 +306,17 @@ class SermondistributorModelSermons extends JModelList } // Filter by preacher. - if ($preacher = $this->getState('filter.preacher')) + $preacher = $this->getState('filter.preacher'); + + if (is_numeric($preacher)) { - $query->where('a.preacher = ' . $db->quote($db->escape($preacher))); + $query->where('a.preacher = ' . (int) $preacher); + } + elseif (is_array($preacher)) + { + $preacher = ArrayHelper::toInteger($preacher); + $preacher = implode(',', $preacher); + $query->where('a.preacher IN (' . $preacher . ')'); } // Filter by series. if ($series = $this->getState('filter.series')) @@ -294,9 +329,17 @@ class SermondistributorModelSermons extends JModelList $query->where('a.link_type = ' . $db->quote($db->escape($link_type))); } // Filter by Source. - if ($source = $this->getState('filter.source')) + $source = $this->getState('filter.source'); + + if (is_numeric($source)) { - $query->where('a.source = ' . $db->quote($db->escape($source))); + $query->where('a.source = ' . (int) $source); + } + elseif (is_array($source)) + { + $source = ArrayHelper::toInteger($source); + $source = implode(',', $source); + $query->where('a.source IN (' . $source . ')'); } // Filter by a single or group of categories. @@ -317,7 +360,7 @@ class SermondistributorModelSermons extends JModelList { ArrayHelper::toInteger($categoryId); $categoryId = implode(',', $categoryId); - $query->where('a.category IN (' . $categoryId . ')'); + $query->where('a.catid IN (' . $categoryId . ')'); } @@ -329,7 +372,7 @@ class SermondistributorModelSermons extends JModelList $query->order($db->escape($orderCol . ' ' . $orderDirn)); } - return $query; + return $query; } /** @@ -435,16 +478,16 @@ class SermondistributorModelSermons extends JModelList return $headers; } return false; - } - - /** - * Method to get a store id based on model configuration state. - * - * @return string A store id. - * - */ - protected function getStoreId($id = '') - { + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { // Compile the store id. $id .= ':' . $this->getState('filter.id'); $id .= ':' . $this->getState('filter.search'); @@ -460,9 +503,9 @@ class SermondistributorModelSermons extends JModelList $id .= ':' . $this->getState('filter.category_id'); $id .= ':' . $this->getState('filter.catid'); $id .= ':' . $this->getState('filter.link_type'); - $id .= ':' . $this->getState('filter.source'); - - return parent::getStoreId($id); + $id .= ':' . $this->getState('filter.source'); + + return parent::getStoreId($id); } /** @@ -502,12 +545,12 @@ class SermondistributorModelSermons extends JModelList // Conditions for which records should be updated. $conditions = array( - $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out') . '!=0', $db->quoteName('checked_out_time') . '<\''.$date.'\'' ); // Check table - $query->update($db->quoteName('#__sermondistributor_sermon'))->set($fields)->where($conditions); + $query->update($db->quoteName('#__sermondistributor_sermon'))->set($fields)->where($conditions); $db->setQuery($query); @@ -516,5 +559,5 @@ class SermondistributorModelSermons extends JModelList } return false; - } -} + } +} diff --git a/admin/views/sermons/tmpl/default.php b/admin/views/sermons/tmpl/default.php index a4e5b232..a35e6eb0 100644 --- a/admin/views/sermons/tmpl/default.php +++ b/admin/views/sermons/tmpl/default.php @@ -1,4 +1,4 @@ - + @author Llewellyn van der Merwe @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - A sermon distributor that links to Dropbox. - + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + A sermon distributor that links to Dropbox. + /----------------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die('Restricted access'); // load tooltip behavior JHtml::_('behavior.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY'))); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_ACCESS'))); +JHtml::_('formbehavior.chosen', '.multiplePreachers', null, array('placeholder_text_multiple' => JText::_('Select preachers'))); +JHtml::_('formbehavior.chosen', '.multipleSource', null, array('placeholder_text_multiple' => JText::_('Select source'))); JHtml::_('formbehavior.chosen', 'select'); if ($this->saveOrder) @@ -38,23 +42,6 @@ if ($this->saveOrder) } ?> -
sidebar)): ?>
@@ -64,13 +51,15 @@ if ($this->saveOrder)
+ $this)); + ?> items)): ?> - loadTemplate('toolbar');?>
- loadTemplate('toolbar');?> loadTemplate('head');?>loadTemplate('foot');?> @@ -88,11 +77,9 @@ if ($this->saveOrder) $this->loadTemplate('batch_body') ); ?> - - - \ No newline at end of file + diff --git a/admin/views/sermons/tmpl/default_body.php b/admin/views/sermons/tmpl/default_body.php index a9e0088b..3c189854 100644 --- a/admin/views/sermons/tmpl/default_body.php +++ b/admin/views/sermons/tmpl/default_body.php @@ -1,33 +1,33 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - A sermon distributor that links to Dropbox. - -/----------------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -$edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit"; - -?> +/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + ____ ____ __ __ __ +/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ +\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ + \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ + /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ + \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ + \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ + +/------------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.0.x + @created 22nd October, 2015 + @package Sermon Distributor + @subpackage default_body.php + @author Llewellyn van der Merwe + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + A sermon distributor that links to Dropbox. + +/----------------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit"; + +?> items as $i => $item): ?> user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; @@ -40,7 +40,7 @@ $edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit"; saveOrder) { - $iconClass = ' inactive'; + $iconClass = ''; } else { @@ -140,4 +140,4 @@ $edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit"; id; ?> - \ No newline at end of file + diff --git a/admin/views/sermons/tmpl/default_head.php b/admin/views/sermons/tmpl/default_head.php index 10a0a538..a5bc9d9e 100644 --- a/admin/views/sermons/tmpl/default_head.php +++ b/admin/views/sermons/tmpl/default_head.php @@ -1,35 +1,35 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - A sermon distributor that links to Dropbox. - -/----------------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -?> +/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + ____ ____ __ __ __ +/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ +\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ + \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ + /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ + \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ + \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ + +/------------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.0.x + @created 22nd October, 2015 + @package Sermon Distributor + @subpackage default_head.php + @author Llewellyn van der Merwe + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + A sermon distributor that links to Dropbox. + +/----------------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> canEdit&& $this->canState): ?> canState): ?> - \ No newline at end of file + diff --git a/admin/views/sermons/view.html.php b/admin/views/sermons/view.html.php index 91ef32bb..373ab004 100644 --- a/admin/views/sermons/view.html.php +++ b/admin/views/sermons/view.html.php @@ -1,211 +1,195 @@ - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html - - A sermon distributor that links to Dropbox. - -/----------------------------------------------------------------------------------------------------------------------------------*/ - -// No direct access to this file -defined('_JEXEC') or die('Restricted access'); - -/** - * Sermondistributor View class for the Sermons - */ -class SermondistributorViewSermons extends JViewLegacy -{ - /** - * Sermons view display method - * @return void - */ - function display($tpl = null) - { - if ($this->getLayout() !== 'modal') - { - // Include helper submenu - SermondistributorHelper::addSubmenu('sermons'); - } - - // Assign data to the view - $this->items = $this->get('Items'); - $this->pagination = $this->get('Pagination'); - $this->state = $this->get('State'); +/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + ____ ____ __ __ __ +/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ +\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ + \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ + /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ + \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ + \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ + +/------------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.0.x + @created 22nd October, 2015 + @package Sermon Distributor + @subpackage view.html.php + @author Llewellyn van der Merwe + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + + A sermon distributor that links to Dropbox. + +/----------------------------------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +/** + * Sermondistributor View class for the Sermons + */ +class SermondistributorViewSermons extends JViewLegacy +{ + /** + * Sermons view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + SermondistributorHelper::addSubmenu('sermons'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); $this->user = JFactory::getUser(); // Add the list ordering clause. $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); - $this->listDirn = $this->escape($this->state->get('list.direction', 'asc')); - $this->saveOrder = $this->listOrder == 'ordering'; - // set the return here value - $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); - // get global action permissions + $this->listDirn = $this->escape($this->state->get('list.direction', 'asc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions $this->canDo = SermondistributorHelper::getActions('sermon'); $this->canEdit = $this->canDo->get('sermon.edit'); $this->canState = $this->canDo->get('sermon.edit.state'); $this->canCreate = $this->canDo->get('sermon.create'); $this->canDelete = $this->canDo->get('sermon.delete'); - $this->canBatch = $this->canDo->get('core.batch'); - - // We don't need toolbar in the modal window. - if ($this->getLayout() !== 'modal') - { - $this->addToolbar(); - $this->sidebar = JHtmlSidebar::render(); - // load the batch html - if ($this->canCreate && $this->canEdit && $this->canState) - { - $this->batchDisplay = JHtmlBatch_::render(); - } - } - - // Check for errors. - if (count($errors = $this->get('Errors'))) - { - throw new Exception(implode("\n", $errors), 500); - } - - // Display the template - parent::display($tpl); - - // Set the document - $this->setDocument(); - } - - /** - * Setting the toolbar - */ - protected function addToolBar() - { - JToolBarHelper::title(JText::_('COM_SERMONDISTRIBUTOR_SERMONS'), 'book'); - JHtmlSidebar::setAction('index.php?option=com_sermondistributor&view=sermons'); - JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - if ($this->canCreate) - { - JToolBarHelper::addNew('sermon.add'); - } - - // Only load if there are items - if (SermondistributorHelper::checkArray($this->items)) - { - if ($this->canEdit) - { - JToolBarHelper::editList('sermon.edit'); - } - - if ($this->canState) - { - JToolBarHelper::publishList('sermons.publish'); - JToolBarHelper::unpublishList('sermons.unpublish'); - JToolBarHelper::archiveList('sermons.archive'); - - if ($this->canDo->get('core.admin')) - { - JToolBarHelper::checkin('sermons.checkin'); - } - } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = JToolBar::getInstance('toolbar'); - // set the batch button name - $title = JText::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new JLayoutFile('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } - - if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) - { - JToolbarHelper::deleteList('', 'sermons.delete', 'JTOOLBAR_EMPTY_TRASH'); - } - elseif ($this->canState && $this->canDelete) - { - JToolbarHelper::trash('sermons.trash'); + $this->canBatch = $this->canDo->get('core.batch'); + $this->filterForm = $this->get('FilterForm'); + $this->activeFilters = $this->get('ActiveFilters'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_SERMONDISTRIBUTOR_SERMONS'), 'book'); + JHtmlSidebar::setAction('index.php?option=com_sermondistributor&view=sermons'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('sermon.add'); + } + + // Only load if there are items + if (SermondistributorHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('sermon.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('sermons.publish'); + JToolBarHelper::unpublishList('sermons.unpublish'); + JToolBarHelper::archiveList('sermons.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('sermons.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'sermons.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('sermons.trash'); } if ($this->canDo->get('core.export') && $this->canDo->get('sermon.export')) { JToolBarHelper::custom('sermons.exportData', 'download', '', 'COM_SERMONDISTRIBUTOR_EXPORT_DATA', true); - } + } } if ($this->canDo->get('core.import') && $this->canDo->get('sermon.import')) { JToolBarHelper::custom('sermons.importData', 'upload', '', 'COM_SERMONDISTRIBUTOR_IMPORT_DATA', false); - } - - // set help url for this view if found - $help_url = SermondistributorHelper::getHelpUrl('sermons'); - if (SermondistributorHelper::checkString($help_url)) - { - JToolbarHelper::help('COM_SERMONDISTRIBUTOR_HELP_MANAGER', false, $help_url); - } - - // add the options comp button - if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) - { - JToolBarHelper::preferences('com_sermondistributor'); - } - - if ($this->canState) - { - JHtmlSidebar::addFilter( - JText::_('JOPTION_SELECT_PUBLISHED'), - 'filter_published', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true) - ); - // only load if batch allowed - if ($this->canBatch) - { - JHtmlBatch_::addListSelection( - JText::_('COM_SERMONDISTRIBUTOR_KEEP_ORIGINAL_STATE'), - 'batch[published]', - JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) - ); - } - } - - JHtmlSidebar::addFilter( - JText::_('JOPTION_SELECT_ACCESS'), - 'filter_access', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access')) - ); - - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - JHtmlBatch_::addListSelection( - JText::_('COM_SERMONDISTRIBUTOR_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') - ); } - // Category Filter. - JHtmlSidebar::addFilter( - JText::_('JOPTION_SELECT_CATEGORY'), - 'filter_category_id', - JHtml::_('select.options', JHtml::_('category.options', 'com_sermondistributor.sermon'), 'value', 'text', $this->state->get('filter.category_id')) - ); + // set help url for this view if found + $help_url = SermondistributorHelper::getHelpUrl('sermons'); + if (SermondistributorHelper::checkString($help_url)) + { + JToolbarHelper::help('COM_SERMONDISTRIBUTOR_HELP_MANAGER', false, $help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_sermondistributor'); + } + + if ($this->canState) + { + // only load if batch allowed + if ($this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_SERMONDISTRIBUTOR_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + } + + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_SERMONDISTRIBUTOR_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } if ($this->canBatch && $this->canCreate && $this->canEdit) { @@ -229,13 +213,6 @@ class SermondistributorViewSermons extends JViewLegacy // Only load Preacher Name filter if it has values if (SermondistributorHelper::checkArray($this->preacherNameOptions)) { - // Preacher Name Filter - JHtmlSidebar::addFilter( - '- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL').' -', - 'filter_preacher', - JHtml::_('select.options', $this->preacherNameOptions, 'value', 'text', $this->state->get('filter.preacher')) - ); - if ($this->canBatch && $this->canCreate && $this->canEdit) { // Preacher Name Batch Selection @@ -259,13 +236,6 @@ class SermondistributorViewSermons extends JViewLegacy // Only load Series Name filter if it has values if (SermondistributorHelper::checkArray($this->seriesNameOptions)) { - // Series Name Filter - JHtmlSidebar::addFilter( - '- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL').' -', - 'filter_series', - JHtml::_('select.options', $this->seriesNameOptions, 'value', 'text', $this->state->get('filter.series')) - ); - if ($this->canBatch && $this->canCreate && $this->canEdit) { // Series Name Batch Selection @@ -289,13 +259,6 @@ class SermondistributorViewSermons extends JViewLegacy // Only load Link Type filter if it has values if (SermondistributorHelper::checkArray($this->link_typeOptions)) { - // Link Type Filter - JHtmlSidebar::addFilter( - '- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL').' -', - 'filter_link_type', - JHtml::_('select.options', $this->link_typeOptions, 'value', 'text', $this->state->get('filter.link_type')) - ); - if ($this->canBatch && $this->canCreate && $this->canEdit) { // Link Type Batch Selection @@ -319,13 +282,6 @@ class SermondistributorViewSermons extends JViewLegacy // Only load Source filter if it has values if (SermondistributorHelper::checkArray($this->sourceOptions)) { - // Source Filter - JHtmlSidebar::addFilter( - '- Select '.JText::_('COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL').' -', - 'filter_source', - JHtml::_('select.options', $this->sourceOptions, 'value', 'text', $this->state->get('filter.source')) - ); - if ($this->canBatch && $this->canCreate && $this->canEdit) { // Source Batch Selection @@ -335,49 +291,49 @@ class SermondistributorViewSermons extends JViewLegacy JHtml::_('select.options', $this->sourceOptions, 'value', 'text') ); } - } - } - - /** - * Method to set up the document properties - * - * @return void - */ - protected function setDocument() - { - if (!isset($this->document)) - { - $this->document = JFactory::getDocument(); - } - $this->document->setTitle(JText::_('COM_SERMONDISTRIBUTOR_SERMONS')); - $this->document->addStyleSheet(JURI::root() . "administrator/components/com_sermondistributor/assets/css/sermons.css", (SermondistributorHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); - } - - /** - * Escapes a value for output in a view script. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - */ - public function escape($var) - { - if(strlen($var) > 50) - { - // use the helper htmlEscape method instead and shorten the string - return SermondistributorHelper::htmlEscape($var, $this->_charset, true); - } - // use the helper htmlEscape method instead. - return SermondistributorHelper::htmlEscape($var, $this->_charset); - } - - /** - * Returns an array of fields the table can be sorted by - * - * @return array Array containing the field name to sort by as the key and display text as value - */ - protected function getSortFields() - { + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_SERMONDISTRIBUTOR_SERMONS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_sermondistributor/assets/css/sermons.css", (SermondistributorHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return SermondistributorHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return SermondistributorHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { return array( 'ordering' => JText::_('JGRID_HEADING_ORDERING'), 'a.published' => JText::_('JSTATUS'), @@ -389,7 +345,7 @@ class SermondistributorViewSermons extends JViewLegacy 'a.link_type' => JText::_('COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL'), 'a.source' => JText::_('COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL'), 'a.id' => JText::_('JGRID_HEADING_ID') - ); + ); } protected function getTheLink_typeSelections() @@ -462,5 +418,5 @@ class SermondistributorViewSermons extends JViewLegacy return $_filter; } return false; - } -} + } +}
- ', 'ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> @@ -43,29 +43,29 @@ defined('_JEXEC') or die('Restricted access'); - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?> @@ -73,6 +73,6 @@ defined('_JEXEC') or die('Restricted access'); - listDirn, $this->listOrder); ?> + listDirn, $this->listOrder); ?>