Modifying the sermons admin view to put the filters on top. #33

Merged
vistamedia merged 2 commits from master into master 2020-11-13 05:14:45 +00:00
7 changed files with 654 additions and 516 deletions
Showing only changes of commit c153288f78 - Show all commits

View File

@ -1,4 +1,4 @@
<?php <?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ /*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __ ____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ /\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
@ -14,12 +14,12 @@
@created 22nd October, 2015 @created 22nd October, 2015
@package Sermon Distributor @package Sermon Distributor
@subpackage preachers.php @subpackage preachers.php
@author Llewellyn van der Merwe <https://www.vdm.io/> @author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved @copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox. A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/ /----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file // No direct access to this file
@ -48,23 +48,25 @@ class JFormFieldPreachers extends JFormFieldList
*/ */
protected function getOptions() protected function getOptions()
{ {
$db = JFactory::getDBO(); $db = JFactory::getDBO();
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name'),array('id','preacher_request_id_name'))); $query->select($db->quoteName(array('a.id','a.name'),array('id','preacher_request_id_name')));
$query->from($db->quoteName('#__sermondistributor_preacher', 'a')); $query->from($db->quoteName('#__sermondistributor_preacher', 'a'));
$query->where($db->quoteName('a.published') . ' = 1'); $query->where($db->quoteName('a.published') . ' = 1');
$query->order('a.name ASC'); $query->order('a.name ASC');
$db->setQuery((string)$query); $db->setQuery((string)$query);
$items = $db->loadObjectList(); $items = $db->loadObjectList();
$options = array(); $options = array();
if ($items) if ($items)
{ {
$options[] = JHtml::_('select.option', '', 'Select a preacher'); if ($this->multiple === false) {
foreach($items as $item) $options[] = JHtml::_('select.option', '', 'Select a preacher');
{ }
$options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name); foreach($items as $item)
} {
} $options[] = JHtml::_('select.option', $item->id, $item->preacher_request_id_name);
}
}
return $options; return $options;
} }
} }

View File

@ -0,0 +1,150 @@
<?xml version="1.0" encoding="utf-8"?>
<form
addrulepath="/administrator/components/com_sermondistributor/models/rules"
addfieldpath="/administrator/components/com_sermondistributor/models/fields"
>
<fields name="filter">
<field
name="search"
type="text"
inputmode="search"
label="COM_CONTENT_FILTER_SEARCH_LABEL"
description="COM_CONTENT_FILTER_SEARCH_DESC"
hint="JSEARCH_FILTER"
/>
<field
name="published"
type="status"
label="COM_CONTENT_FILTER_PUBLISHED"
description="COM_CONTENT_FILTER_PUBLISHED_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field
name="category_id"
type="category"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
multiple="true"
class="multipleCategories"
extension="com_sermondistributor.sermon"
onchange="this.form.submit();"
published="0,1,2"
/>
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
multiple="true"
class="multipleAccessLevels"
onchange="this.form.submit();"
/>
<!-- Preacher Field. Type: Preachers. (custom) -->
<field
type="preachers"
name="preacher"
label="COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_PREACHER_DESCRIPTION"
class="multiplePreachers"
multiple="true"
onchange="this.form.submit();"
/>
<!-- Series Field. Type: Series. (custom) -->
<field
type="series"
name="series"
label="COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_SERIES_DESCRIPTION"
class="list_class"
multiple="false"
onchange="this.form.submit();"
/>
<!-- Link_type Field. Type: Radio. (joomla) -->
<field
type="list"
name="link_type"
label="COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_DESCRIPTION"
class="list_class"
onchange="this.form.submit();"
>
<!-- Option Set. -->
<option value="">
Select link type</option>
<option value="1">
COM_SERMONDISTRIBUTOR_SERMON_ENCRYPTED</option>
<option value="2">
COM_SERMONDISTRIBUTOR_SERMON_DIRECT</option>
</field>
<!-- Source Field. Type: List. (joomla) -->
<field
type="list"
name="source"
label="COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL"
description="COM_SERMONDISTRIBUTOR_SERMON_SOURCE_DESCRIPTION"
class="multipleSource"
multiple="true"
onchange="this.form.submit();"
>
<!-- Option Set. -->
<option value="1">
COM_SERMONDISTRIBUTOR_SERMON_LOCAL_FOLDER</option>
<option value="2">
COM_SERMONDISTRIBUTOR_SERMON_EXTERNAL_SOURCE</option>
<option value="3">
COM_SERMONDISTRIBUTOR_SERMON_URL</option>
</field>
<input type="hidden" name="form_submited" value="1"/>
</fields>
<fields name="list">
<field
name="fullordering"
type="list"
label="COM_CONTENT_LIST_FULL_ORDERING"
description="COM_CONTENT_LIST_FULL_ORDERING_DESC"
onchange="this.form.submit();"
default="a.id DESC"
validate="options"
>
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.published ASC">JSTATUS_ASC</option>
<option value="a.published DESC">JSTATUS_DESC</option>
<option value="a.name ASC">Name ASC</option>
<option value="a.name DESC">Name DESC</option>
<option value="g.name ASC">Preacher ASC</option>
<option value="g.name DESC">Preacher DESC</option>
<option value="h.name ASC">Series ASC</option>
<option value="h.name DESC">Series DESC</option>
<option value="a.short_description ASC">Short description ASC</option>
<option value="a.short_description DESC">Short description DESC</option>
<option value="category_title ASC">Sermon categories ASC</option>
<option value="category_title DESC">Sermon categories DESC</option>
<option value="a.link_type ASC">Download Link Option ASC</option>
<option value="a.link_type DESC">Download Link Option DESC</option>
<option value="a.source ASC">File source ASC</option>
<option value="a.source DESC">File source DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>
<field
name="limit"
type="limitbox"
label="COM_CONTENT_LIST_LIMIT"
description="COM_CONTENT_LIST_LIMIT_DESC"
class="input-mini"
default="25"
onchange="this.form.submit();"
/>
</fields>
</form>

View File

@ -1,81 +1,82 @@
<?php <?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ /*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __ ____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ /\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ \ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/ /------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x @version 2.0.x
@created 22nd October, 2015 @created 22nd October, 2015
@package Sermon Distributor @package Sermon Distributor
@subpackage sermons.php @subpackage sermons.php
@author Llewellyn van der Merwe <https://www.vdm.io/> @author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved @copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox. A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/ /----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper; use Joomla\Utilities\ArrayHelper;
/** /**
* Sermons Model * Sermons Model
*/ */
class SermondistributorModelSermons extends JModelList class SermondistributorModelSermons extends JModelList
{ {
public function __construct($config = array()) public function __construct($config = array())
{ {
if (empty($config['filter_fields'])) if (empty($config['filter_fields']))
{ {
$config['filter_fields'] = array( $config['filter_fields'] = array(
'a.id','id', 'a.id','id',
'a.published','published', 'a.published','published',
'a.ordering','ordering', 'a.ordering','ordering',
'a.created_by','created_by', 'a.created_by','created_by',
'a.modified_by','modified_by', 'a.modified_by','modified_by',
'a.access','access',
'a.name','name', 'a.name','name',
'g.name', 'g.name','preacher',
'h.name', 'h.name','series',
'a.short_description','short_description', 'a.short_description','short_description',
'c.title','category_title', 'c.title','category_title',
'c.id', 'category_id', 'c.id', 'category_id',
'a.catid', 'catid', 'a.catid', 'catid',
'a.link_type','link_type', 'a.link_type','link_type',
'a.source','source' 'a.source','source'
); );
} }
parent::__construct($config); parent::__construct($config);
} }
/** /**
* Method to auto-populate the model state. * Method to auto-populate the model state.
* *
* @return void * @return void
*/ */
protected function populateState($ordering = null, $direction = null) protected function populateState($ordering = null, $direction = null)
{ {
$app = JFactory::getApplication(); $app = JFactory::getApplication();
// Adjust the context to support modal layouts. // Adjust the context to support modal layouts.
if ($layout = $app->input->get('layout')) if ($layout = $app->input->get('layout'))
{ {
$this->context .= '.' . $layout; $this->context .= '.' . $layout;
} }
$name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name');
$this->setState('filter.name', $name); $this->setState('filter.name', $name);
$preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher'); // $preacher = $this->getUserStateFromRequest($this->context . '.filter.preacher', 'filter_preacher');
$this->setState('filter.preacher', $preacher); // $this->setState('filter.preacher', $preacher);
$series = $this->getUserStateFromRequest($this->context . '.filter.series', 'filter_series'); $series = $this->getUserStateFromRequest($this->context . '.filter.series', 'filter_series');
$this->setState('filter.series', $series); $this->setState('filter.series', $series);
@ -86,8 +87,8 @@ class SermondistributorModelSermons extends JModelList
$category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category'); $category = $app->getUserStateFromRequest($this->context . '.filter.category', 'filter_category');
$this->setState('filter.category', $category); $this->setState('filter.category', $category);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); // $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
$this->setState('filter.category_id', $categoryId); // $this->setState('filter.category_id', $categoryId);
$catid = $app->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid'); $catid = $app->getUserStateFromRequest($this->context . '.filter.catid', 'filter_catid');
$this->setState('filter.catid', $catid); $this->setState('filter.catid', $catid);
@ -96,41 +97,58 @@ class SermondistributorModelSermons extends JModelList
$this->setState('filter.link_type', $link_type); $this->setState('filter.link_type', $link_type);
$source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source'); $source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source');
$this->setState('filter.source', $source); $this->setState('filter.source', $source);
$sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
$this->setState('filter.sorting', $sorting); $this->setState('filter.sorting', $sorting);
$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
$this->setState('filter.access', $access); $this->setState('filter.access', $access);
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search); $this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
$this->setState('filter.published', $published); $this->setState('filter.published', $published);
$created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', '');
$this->setState('filter.created_by', $created_by); $this->setState('filter.created_by', $created_by);
$created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created');
$this->setState('filter.created', $created); $this->setState('filter.created', $created);
// List state information. // Handle multiple fields -> original code commented above
parent::populateState($ordering, $direction); $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');
* Method to get an array of data items. if ($formSubmited)
* {
* @return mixed An array of data items on success, false on failure. $access = $app->input->post->get('access');
*/ $this->setState('filter.access', $access);
public function getItems()
$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 // check in items
$this->checkInNow(); $this->checkInNow();
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// Set values to display correctly. // Set values to display correctly.
@ -165,10 +183,10 @@ class SermondistributorModelSermons extends JModelList
$item->source = $this->selectionTranslation($item->source, 'source'); $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; return $value;
} }
/** /**
* Method to build an SQL query to load the list data. * Method to build an SQL query to load the list data.
* *
* @return string An SQL query * @return string An SQL query
*/ */
protected function getListQuery() protected function getListQuery()
{ {
// Get the user object. // Get the user object.
$user = JFactory::getUser(); $user = JFactory::getUser();
// Create a new query object. // Create a new query object.
@ -253,10 +271,19 @@ class SermondistributorModelSermons extends JModelList
$query->select('ag.title AS access_level'); $query->select('ag.title AS access_level');
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
// Filter by access level. // 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); $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 // Implement View Level Access
if (!$user->authorise('core.options', 'com_sermondistributor')) if (!$user->authorise('core.options', 'com_sermondistributor'))
{ {
@ -279,9 +306,17 @@ class SermondistributorModelSermons extends JModelList
} }
// Filter by preacher. // 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. // Filter by series.
if ($series = $this->getState('filter.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))); $query->where('a.link_type = ' . $db->quote($db->escape($link_type)));
} }
// Filter by Source. // 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. // Filter by a single or group of categories.
@ -317,7 +360,7 @@ class SermondistributorModelSermons extends JModelList
{ {
ArrayHelper::toInteger($categoryId); ArrayHelper::toInteger($categoryId);
$categoryId = implode(',', $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)); $query->order($db->escape($orderCol . ' ' . $orderDirn));
} }
return $query; return $query;
} }
/** /**
@ -435,16 +478,16 @@ class SermondistributorModelSermons extends JModelList
return $headers; return $headers;
} }
return false; return false;
} }
/** /**
* Method to get a store id based on model configuration state. * Method to get a store id based on model configuration state.
* *
* @return string A store id. * @return string A store id.
* *
*/ */
protected function getStoreId($id = '') protected function getStoreId($id = '')
{ {
// Compile the store id. // Compile the store id.
$id .= ':' . $this->getState('filter.id'); $id .= ':' . $this->getState('filter.id');
$id .= ':' . $this->getState('filter.search'); $id .= ':' . $this->getState('filter.search');
@ -460,9 +503,9 @@ class SermondistributorModelSermons extends JModelList
$id .= ':' . $this->getState('filter.category_id'); $id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.catid'); $id .= ':' . $this->getState('filter.catid');
$id .= ':' . $this->getState('filter.link_type'); $id .= ':' . $this->getState('filter.link_type');
$id .= ':' . $this->getState('filter.source'); $id .= ':' . $this->getState('filter.source');
return parent::getStoreId($id); return parent::getStoreId($id);
} }
/** /**
@ -502,12 +545,12 @@ class SermondistributorModelSermons extends JModelList
// Conditions for which records should be updated. // Conditions for which records should be updated.
$conditions = array( $conditions = array(
$db->quoteName('checked_out') . '!=0', $db->quoteName('checked_out') . '!=0',
$db->quoteName('checked_out_time') . '<\''.$date.'\'' $db->quoteName('checked_out_time') . '<\''.$date.'\''
); );
// Check table // 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); $db->setQuery($query);
@ -516,5 +559,5 @@ class SermondistributorModelSermons extends JModelList
} }
return false; return false;
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ /*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __ ____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ /\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
@ -14,21 +14,25 @@
@created 22nd October, 2015 @created 22nd October, 2015
@package Sermon Distributor @package Sermon Distributor
@subpackage default.php @subpackage default.php
@author Llewellyn van der Merwe <https://www.vdm.io/> @author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved @copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox. A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/ /----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
// load tooltip behavior // load tooltip behavior
JHtml::_('behavior.tooltip'); JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect'); JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init'); 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'); JHtml::_('formbehavior.chosen', 'select');
if ($this->saveOrder) if ($this->saveOrder)
@ -38,23 +42,6 @@ if ($this->saveOrder)
} }
?> ?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $this->listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_sermondistributor&view=sermons'); ?>" method="post" name="adminForm" id="adminForm"> <form action="<?php echo JRoute::_('index.php?option=com_sermondistributor&view=sermons'); ?>" method="post" name="adminForm" id="adminForm">
<?php if(!empty( $this->sidebar)): ?> <?php if(!empty( $this->sidebar)): ?>
<div id="j-sidebar-container" class="span2"> <div id="j-sidebar-container" class="span2">
@ -64,13 +51,15 @@ if ($this->saveOrder)
<?php else : ?> <?php else : ?>
<div id="j-main-container"> <div id="j-main-container">
<?php endif; ?> <?php endif; ?>
<?php
// Search tools bar
echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this));
?>
<?php if (empty($this->items)): ?> <?php if (empty($this->items)): ?>
<?php echo $this->loadTemplate('toolbar');?>
<div class="alert alert-no-items"> <div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> <?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div> </div>
<?php else : ?> <?php else : ?>
<?php echo $this->loadTemplate('toolbar');?>
<table class="table table-striped" id="sermonList"> <table class="table table-striped" id="sermonList">
<thead><?php echo $this->loadTemplate('head');?></thead> <thead><?php echo $this->loadTemplate('head');?></thead>
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot> <tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
@ -88,11 +77,9 @@ if ($this->saveOrder)
$this->loadTemplate('batch_body') $this->loadTemplate('batch_body')
); ?> ); ?>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="filter_order" value="<?php echo $this->listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->listDirn; ?>" />
<input type="hidden" name="boxchecked" value="0" /> <input type="hidden" name="boxchecked" value="0" />
</div> </div>
<?php endif; ?> <?php endif; ?>
<input type="hidden" name="task" value="" /> <input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?> <?php echo JHtml::_('form.token'); ?>
</form> </form>

View File

@ -1,33 +1,33 @@
<?php <?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ /*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __ ____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ /\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ \ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/ /------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x @version 2.0.x
@created 22nd October, 2015 @created 22nd October, 2015
@package Sermon Distributor @package Sermon Distributor
@subpackage default_body.php @subpackage default_body.php
@author Llewellyn van der Merwe <https://www.vdm.io/> @author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved @copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox. A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/ /----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
$edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit"; $edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit";
?> ?>
<?php foreach ($this->items as $i => $item): ?> <?php foreach ($this->items as $i => $item): ?>
<?php <?php
$canCheckin = $this->user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; $canCheckin = $this->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";
<?php <?php
if ($this->saveOrder) if ($this->saveOrder)
{ {
$iconClass = ' inactive'; $iconClass = '';
} }
else else
{ {
@ -140,4 +140,4 @@ $edit = "index.php?option=com_sermondistributor&view=sermons&task=sermon.edit";
<?php echo $item->id; ?> <?php echo $item->id; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -1,35 +1,35 @@
<?php <?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ /*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __ ____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ /\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ \ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/ /------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x @version 2.0.x
@created 22nd October, 2015 @created 22nd October, 2015
@package Sermon Distributor @package Sermon Distributor
@subpackage default_head.php @subpackage default_head.php
@author Llewellyn van der Merwe <https://www.vdm.io/> @author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved @copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox. A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/ /----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
?> ?>
<tr> <tr>
<?php if ($this->canEdit&& $this->canState): ?> <?php if ($this->canEdit&& $this->canState): ?>
<th width="1%" class="nowrap center hidden-phone"> <th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?> <?php echo JHtml::_('searchtools.sort', '', 'a.ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?>
</th> </th>
<th width="20" class="nowrap center"> <th width="20" class="nowrap center">
<?php echo JHtml::_('grid.checkall'); ?> <?php echo JHtml::_('grid.checkall'); ?>
@ -43,29 +43,29 @@ defined('_JEXEC') or die('Restricted access');
</th> </th>
<?php endif; ?> <?php endif; ?>
<th class="nowrap" > <th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_NAME_LABEL', 'a.name', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_NAME_LABEL', 'a.name', $this->listDirn, $this->listOrder); ?>
</th> </th>
<th class="nowrap" > <th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL', 'g.name', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_PREACHER_LABEL', 'g.name', $this->listDirn, $this->listOrder); ?>
</th> </th>
<th class="nowrap" > <th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL', 'h.name', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERIES_LABEL', 'h.name', $this->listDirn, $this->listOrder); ?>
</th> </th>
<th class="nowrap hidden-phone" > <th class="nowrap hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SHORT_DESCRIPTION_LABEL', 'a.short_description', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SHORT_DESCRIPTION_LABEL', 'a.short_description', $this->listDirn, $this->listOrder); ?>
</th> </th>
<th class="nowrap" > <th class="nowrap" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERMONS_CATEGORIES', 'category_title', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SERMONS_CATEGORIES', 'category_title', $this->listDirn, $this->listOrder); ?>
</th> </th>
<th class="nowrap hidden-phone" > <th class="nowrap hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL', 'a.link_type', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL', 'a.link_type', $this->listDirn, $this->listOrder); ?>
</th> </th>
<th class="nowrap hidden-phone" > <th class="nowrap hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL', 'a.source', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL', 'a.source', $this->listDirn, $this->listOrder); ?>
</th> </th>
<?php if ($this->canState): ?> <?php if ($this->canState): ?>
<th width="10" class="nowrap center" > <th width="10" class="nowrap center" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_STATUS', 'a.published', $this->listDirn, $this->listOrder); ?>
</th> </th>
<?php else: ?> <?php else: ?>
<th width="10" class="nowrap center" > <th width="10" class="nowrap center" >
@ -73,6 +73,6 @@ defined('_JEXEC') or die('Restricted access');
</th> </th>
<?php endif; ?> <?php endif; ?>
<th width="5" class="nowrap center hidden-phone" > <th width="5" class="nowrap center hidden-phone" >
<?php echo JHtml::_('grid.sort', 'COM_SERMONDISTRIBUTOR_SERMON_ID', 'a.id', $this->listDirn, $this->listOrder); ?> <?php echo JHtml::_('searchtools.sort', 'COM_SERMONDISTRIBUTOR_SERMON_ID', 'a.id', $this->listDirn, $this->listOrder); ?>
</th> </th>
</tr> </tr>

View File

@ -1,211 +1,195 @@
<?php <?php
/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/ /*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __ ____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__ /\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __ \ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\ \/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/ /\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\ \ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/ \/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/ /------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x @version 2.0.x
@created 22nd October, 2015 @created 22nd October, 2015
@package Sermon Distributor @package Sermon Distributor
@subpackage view.html.php @subpackage view.html.php
@author Llewellyn van der Merwe <https://www.vdm.io/> @author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved @copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox. A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/ /----------------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
/** /**
* Sermondistributor View class for the Sermons * Sermondistributor View class for the Sermons
*/ */
class SermondistributorViewSermons extends JViewLegacy class SermondistributorViewSermons extends JViewLegacy
{ {
/** /**
* Sermons view display method * Sermons view display method
* @return void * @return void
*/ */
function display($tpl = null) function display($tpl = null)
{ {
if ($this->getLayout() !== 'modal') if ($this->getLayout() !== 'modal')
{ {
// Include helper submenu // Include helper submenu
SermondistributorHelper::addSubmenu('sermons'); SermondistributorHelper::addSubmenu('sermons');
} }
// Assign data to the view // Assign data to the view
$this->items = $this->get('Items'); $this->items = $this->get('Items');
$this->pagination = $this->get('Pagination'); $this->pagination = $this->get('Pagination');
$this->state = $this->get('State'); $this->state = $this->get('State');
$this->user = JFactory::getUser(); $this->user = JFactory::getUser();
// Add the list ordering clause. // Add the list ordering clause.
$this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id'));
$this->listDirn = $this->escape($this->state->get('list.direction', 'asc')); $this->listDirn = $this->escape($this->state->get('list.direction', 'asc'));
$this->saveOrder = $this->listOrder == 'ordering'; $this->saveOrder = $this->listOrder == 'a.ordering';
// set the return here value // set the return here value
$this->return_here = urlencode(base64_encode((string) JUri::getInstance())); $this->return_here = urlencode(base64_encode((string) JUri::getInstance()));
// get global action permissions // get global action permissions
$this->canDo = SermondistributorHelper::getActions('sermon'); $this->canDo = SermondistributorHelper::getActions('sermon');
$this->canEdit = $this->canDo->get('sermon.edit'); $this->canEdit = $this->canDo->get('sermon.edit');
$this->canState = $this->canDo->get('sermon.edit.state'); $this->canState = $this->canDo->get('sermon.edit.state');
$this->canCreate = $this->canDo->get('sermon.create'); $this->canCreate = $this->canDo->get('sermon.create');
$this->canDelete = $this->canDo->get('sermon.delete'); $this->canDelete = $this->canDo->get('sermon.delete');
$this->canBatch = $this->canDo->get('core.batch'); $this->canBatch = $this->canDo->get('core.batch');
$this->filterForm = $this->get('FilterForm');
// We don't need toolbar in the modal window. $this->activeFilters = $this->get('ActiveFilters');
if ($this->getLayout() !== 'modal')
{ // We don't need toolbar in the modal window.
$this->addToolbar(); if ($this->getLayout() !== 'modal')
$this->sidebar = JHtmlSidebar::render(); {
// load the batch html $this->addToolbar();
if ($this->canCreate && $this->canEdit && $this->canState) $this->sidebar = JHtmlSidebar::render();
{ // load the batch html
$this->batchDisplay = JHtmlBatch_::render(); if ($this->canCreate && $this->canEdit && $this->canState)
} {
} $this->batchDisplay = JHtmlBatch_::render();
}
// Check for errors. }
if (count($errors = $this->get('Errors')))
{ // Check for errors.
throw new Exception(implode("\n", $errors), 500); if (count($errors = $this->get('Errors')))
} {
throw new Exception(implode("\n", $errors), 500);
// Display the template }
parent::display($tpl);
// Display the template
// Set the document parent::display($tpl);
$this->setDocument();
} // Set the document
$this->setDocument();
/** }
* Setting the toolbar
*/ /**
protected function addToolBar() * Setting the toolbar
{ */
JToolBarHelper::title(JText::_('COM_SERMONDISTRIBUTOR_SERMONS'), 'book'); protected function addToolBar()
JHtmlSidebar::setAction('index.php?option=com_sermondistributor&view=sermons'); {
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); JToolBarHelper::title(JText::_('COM_SERMONDISTRIBUTOR_SERMONS'), 'book');
JHtmlSidebar::setAction('index.php?option=com_sermondistributor&view=sermons');
if ($this->canCreate) JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
{
JToolBarHelper::addNew('sermon.add'); if ($this->canCreate)
} {
JToolBarHelper::addNew('sermon.add');
// Only load if there are items }
if (SermondistributorHelper::checkArray($this->items))
{ // Only load if there are items
if ($this->canEdit) if (SermondistributorHelper::checkArray($this->items))
{ {
JToolBarHelper::editList('sermon.edit'); if ($this->canEdit)
} {
JToolBarHelper::editList('sermon.edit');
if ($this->canState) }
{
JToolBarHelper::publishList('sermons.publish'); if ($this->canState)
JToolBarHelper::unpublishList('sermons.unpublish'); {
JToolBarHelper::archiveList('sermons.archive'); JToolBarHelper::publishList('sermons.publish');
JToolBarHelper::unpublishList('sermons.unpublish');
if ($this->canDo->get('core.admin')) JToolBarHelper::archiveList('sermons.archive');
{
JToolBarHelper::checkin('sermons.checkin'); if ($this->canDo->get('core.admin'))
} {
} JToolBarHelper::checkin('sermons.checkin');
}
// Add a batch button }
if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState)
{ // Add a batch button
// Get the toolbar object instance if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState)
$bar = JToolBar::getInstance('toolbar'); {
// set the batch button name // Get the toolbar object instance
$title = JText::_('JTOOLBAR_BATCH'); $bar = JToolBar::getInstance('toolbar');
// Instantiate a new JLayoutFile instance and render the batch button // set the batch button name
$layout = new JLayoutFile('joomla.toolbar.batch'); $title = JText::_('JTOOLBAR_BATCH');
// add the button to the page // Instantiate a new JLayoutFile instance and render the batch button
$dhtml = $layout->render(array('title' => $title)); $layout = new JLayoutFile('joomla.toolbar.batch');
$bar->appendButton('Custom', $dhtml, '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'); if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete))
} {
elseif ($this->canState && $this->canDelete) JToolbarHelper::deleteList('', 'sermons.delete', 'JTOOLBAR_EMPTY_TRASH');
{ }
JToolbarHelper::trash('sermons.trash'); elseif ($this->canState && $this->canDelete)
{
JToolbarHelper::trash('sermons.trash');
} }
if ($this->canDo->get('core.export') && $this->canDo->get('sermon.export')) if ($this->canDo->get('core.export') && $this->canDo->get('sermon.export'))
{ {
JToolBarHelper::custom('sermons.exportData', 'download', '', 'COM_SERMONDISTRIBUTOR_EXPORT_DATA', true); JToolBarHelper::custom('sermons.exportData', 'download', '', 'COM_SERMONDISTRIBUTOR_EXPORT_DATA', true);
} }
} }
if ($this->canDo->get('core.import') && $this->canDo->get('sermon.import')) if ($this->canDo->get('core.import') && $this->canDo->get('sermon.import'))
{ {
JToolBarHelper::custom('sermons.importData', 'upload', '', 'COM_SERMONDISTRIBUTOR_IMPORT_DATA', false); 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. // set help url for this view if found
JHtmlSidebar::addFilter( $help_url = SermondistributorHelper::getHelpUrl('sermons');
JText::_('JOPTION_SELECT_CATEGORY'), if (SermondistributorHelper::checkString($help_url))
'filter_category_id', {
JHtml::_('select.options', JHtml::_('category.options', 'com_sermondistributor.sermon'), 'value', 'text', $this->state->get('filter.category_id')) 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) if ($this->canBatch && $this->canCreate && $this->canEdit)
{ {
@ -229,13 +213,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Preacher Name filter if it has values // Only load Preacher Name filter if it has values
if (SermondistributorHelper::checkArray($this->preacherNameOptions)) 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) if ($this->canBatch && $this->canCreate && $this->canEdit)
{ {
// Preacher Name Batch Selection // Preacher Name Batch Selection
@ -259,13 +236,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Series Name filter if it has values // Only load Series Name filter if it has values
if (SermondistributorHelper::checkArray($this->seriesNameOptions)) 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) if ($this->canBatch && $this->canCreate && $this->canEdit)
{ {
// Series Name Batch Selection // Series Name Batch Selection
@ -289,13 +259,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Link Type filter if it has values // Only load Link Type filter if it has values
if (SermondistributorHelper::checkArray($this->link_typeOptions)) 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) if ($this->canBatch && $this->canCreate && $this->canEdit)
{ {
// Link Type Batch Selection // Link Type Batch Selection
@ -319,13 +282,6 @@ class SermondistributorViewSermons extends JViewLegacy
// Only load Source filter if it has values // Only load Source filter if it has values
if (SermondistributorHelper::checkArray($this->sourceOptions)) 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) if ($this->canBatch && $this->canCreate && $this->canEdit)
{ {
// Source Batch Selection // Source Batch Selection
@ -335,49 +291,49 @@ class SermondistributorViewSermons extends JViewLegacy
JHtml::_('select.options', $this->sourceOptions, 'value', 'text') JHtml::_('select.options', $this->sourceOptions, 'value', 'text')
); );
} }
} }
} }
/** /**
* Method to set up the document properties * Method to set up the document properties
* *
* @return void * @return void
*/ */
protected function setDocument() protected function setDocument()
{ {
if (!isset($this->document)) if (!isset($this->document))
{ {
$this->document = JFactory::getDocument(); $this->document = JFactory::getDocument();
} }
$this->document->setTitle(JText::_('COM_SERMONDISTRIBUTOR_SERMONS')); $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'); $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. * Escapes a value for output in a view script.
* *
* @param mixed $var The output to escape. * @param mixed $var The output to escape.
* *
* @return mixed The escaped value. * @return mixed The escaped value.
*/ */
public function escape($var) public function escape($var)
{ {
if(strlen($var) > 50) if(strlen($var) > 50)
{ {
// use the helper htmlEscape method instead and shorten the string // use the helper htmlEscape method instead and shorten the string
return SermondistributorHelper::htmlEscape($var, $this->_charset, true); return SermondistributorHelper::htmlEscape($var, $this->_charset, true);
} }
// use the helper htmlEscape method instead. // use the helper htmlEscape method instead.
return SermondistributorHelper::htmlEscape($var, $this->_charset); return SermondistributorHelper::htmlEscape($var, $this->_charset);
} }
/** /**
* Returns an array of fields the table can be sorted by * 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 * @return array Array containing the field name to sort by as the key and display text as value
*/ */
protected function getSortFields() protected function getSortFields()
{ {
return array( return array(
'ordering' => JText::_('JGRID_HEADING_ORDERING'), 'ordering' => JText::_('JGRID_HEADING_ORDERING'),
'a.published' => JText::_('JSTATUS'), 'a.published' => JText::_('JSTATUS'),
@ -389,7 +345,7 @@ class SermondistributorViewSermons extends JViewLegacy
'a.link_type' => JText::_('COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL'), 'a.link_type' => JText::_('COM_SERMONDISTRIBUTOR_SERMON_LINK_TYPE_LABEL'),
'a.source' => JText::_('COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL'), 'a.source' => JText::_('COM_SERMONDISTRIBUTOR_SERMON_SOURCE_LABEL'),
'a.id' => JText::_('JGRID_HEADING_ID') 'a.id' => JText::_('JGRID_HEADING_ID')
); );
} }
protected function getTheLink_typeSelections() protected function getTheLink_typeSelections()
@ -462,5 +418,5 @@ class SermondistributorViewSermons extends JViewLegacy
return $_filter; return $_filter;
} }
return false; return false;
} }
} }