Skip to content

Commit

Permalink
Overall minor improvements and bug fixes (#9)
Browse files Browse the repository at this point in the history
* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

* Overall minor improvements and bug fixes

Co-authored-by: snehalpatil0904 <[email protected]>
  • Loading branch information
snehal0904 and snehalpatil0904 authored Feb 11, 2020
1 parent dc66b05 commit 413eaf6
Show file tree
Hide file tree
Showing 15 changed files with 270 additions and 346 deletions.
64 changes: 36 additions & 28 deletions src/administrator/models/contents.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ public function __construct($config = array())
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'tc_id', 'a.`tc_id`',
'ordering', 'a.`ordering`',
'state', 'a.`state`',
'created_by', 'a.`created_by`',
'modified_by', 'a.`modified_by`',
'title', 'a.`title`',
'version', 'a.`version`',
'client', 'a.`client`',
'start_date', 'a.`start_date`',
'content', 'a.`content`',
'tc_id', 'a.tc_id',
'ordering', 'a.ordering',
'state', 'a.state',
'created_by', 'a.created_by',
'modified_by', 'a.modified_by',
'title', 'a.title',
'version', 'a.version',
'client', 'a.client',
'start_date', 'a.start_date',
'content', 'a.content'
);
}

Expand All @@ -59,27 +59,20 @@ public function __construct($config = array())
*
* @throws Exception
*/
protected function populateState($ordering = null, $direction = null)
protected function populateState($ordering = 'a.tc_id', $direction = 'DESC')
{
// Initialise variables.
$app = JFactory::getApplication('administrator');

// Load the filter state.
$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);

$published = $app->getUserStateFromRequest($this->context . '.filter.state', 'filter_published', '', 'string');
$this->setState('filter.state', $published);

$show = $app->getUserStateFromRequest($this->context . '.filter.show', 'filter_show', 'latest', 'string');
$this->setState('filter.show', $show);

// Load the parameters.
$params = JComponentHelper::getParams('com_tc');
$this->setState('params', $params);
if ($filters = $app->getUserStateFromRequest($this->context . '.filter', 'filter', array(), 'array'))
{
foreach ($filters as $name => $value)
{
$this->setState('filter.' . $name, $value);
}
}

// List state information.
parent::populateState('a.title', 'asc');
parent::populateState($ordering, $direction);
}

/**
Expand Down Expand Up @@ -154,6 +147,7 @@ protected function getListQuery()

// Filter by published state
$published = $this->getState('filter.state');
$client = $this->getState('filter.client');

if (is_numeric($published))
{
Expand All @@ -164,6 +158,11 @@ protected function getListQuery()
$query->where($db->quoteName('a.state') . 'IN (0, 1)');
}

if (!empty($client))
{
$query->where($db->quoteName('a.client') . ' = ' . $db->quote($client));
}

// Filter by search in title
$search = $this->getState('filter.search');

Expand All @@ -182,14 +181,23 @@ protected function getListQuery()
}

// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
$orderCol = $this->state->get('list.ordering', 'a.tc_id');
$orderDirn = $this->state->get('list.direction', 'DESC');

if ($orderCol && $orderDirn)
{
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}

// Get ordering
$fullorderCol = $this->state->get('list.fullordering', 'a.tc_id DESC');

// Apply ordering
if (!empty($fullorderCol))
{
$query->order($db->escape($fullorderCol));
}

return $query;
}

Expand Down
80 changes: 42 additions & 38 deletions src/administrator/models/forms/content.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="tc_id" type="text" readonly="true" class="readonly" default="0" description="JGLOBAL_FIELD_ID_DESC"/>
<field name="ordering"/>
<field name="state" default="1" type="list" label="JSTATUS" description="JFIELD_PUBLISHED_DESC" class="inputbox" size="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="checked_out" type="hidden" filter="unset"/>
<field name="checked_out_time" default="0000-00-00 00:00:00" type="hidden" filter="unset"/>
<field name="title" required="true" label="COM_TC_FORM_LBL_CONTENT_TITLE" description="COM_TC_FORM_DESC_CONTENT_TITLE" hint="COM_TC_FORM_LBL_CONTENT_TITLE"/>

<field name="version" id="version_id" required="true" class="validate-version" label="COM_TC_FORM_LBL_CONTENT_VERSION" description="COM_TC_FORM_DESC_CONTENT_VERSION" hint="COM_TC_FORM_LBL_CONTENT_VERSION"/>

<field name="client" required="true" id="client_id" class="validate-client" label="COM_TC_FORM_LBL_CONTENT_CLIENT" description="COM_TC_FORM_DESC_CONTENT_CLIENT" hint="COM_TC_FORM_LBL_CONTENT_CLIENT"/>

<field name= "url_pattern" id="url_pattern_id" description= "COM_TC_FORM_LBL_CONTENT_URL_PATTERN_DESC" type= "subform" label= "COM_TC_FORM_LBL_CONTENT_URL_PATTERN" min= "1" max= "1000" formsource= "/administrator/components/com_tc/models/forms/url_pattern.xml" multiple= "true" buttons= "add,remove" layout="joomla.form.field.subform.repeatable-table" groupByFieldset="false"/>
<field name="start_date" default="0000-00-00 00:00:00" type="calendar" class="inputbox" filter="safehtml" format="%Y-%m-%d %H:%M:%S" required="true" label="COM_TC_FORM_LBL_CONTENT_START_DATE" description="COM_TC_FORM_DESC_CONTENT_START_DATE" hint="COM_TC_FORM_LBL_CONTENT_START_DATE"/>
<field name="content" type="editor" filter="raw" label="COM_TC_FORM_LBL_CONTENT_CONTENT" description="COM_TC_FORM_DESC_CONTENT_CONTENT" hint="COM_TC_FORM_LBL_CONTENT_CONTENT"/>
<field name="global" type="radio" class="btn-group" id="global_id" label="COM_TC_FORM_LBL_CONTENT_GLOBAL" description="COM_TC_FORM_LBL_CONTENT_GLOBLA_DESC" default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="groups" type="usergrouplist" multiple="true" default="0" label="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP" description="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP_DESC"/>
<field name="is_blacklist" type="radio" class="btn-group" label="COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR" description="COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_DESC" default="1">
<option value="1">COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_YES</option>
<option value="0">COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_NO</option>
</field>
<field name="enforce_delay_days" required="" label="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY" description="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY_DESC" hint="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY"/>
<field name="created_by" type="hidden" filter="unset"/>
<field name="modified_by" type="hidden" filter="unset"/>
<field name="created_on" type="hidden" filter="unset"/>
<field name="modified_on" type="hidden" filter="unset"/>
</fieldset>
</form>
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field name="tc_id" type="text" readonly="true" class="readonly" default="0" description="JGLOBAL_FIELD_ID_DESC" />
<field name="ordering" type="hidden" filter="integer"/>
<field name="state" default="1" type="list" label="JSTATUS" description="JFIELD_PUBLISHED_DESC" class="inputbox" size="1">
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="checked_out" type="hidden" filter="integer"/>
<field name="checked_out_time" default="0000-00-00 00:00:00" type="hidden" filter="unset" />
<field name="title" required="true" label="COM_TC_FORM_LBL_CONTENT_TITLE" description="COM_TC_FORM_DESC_CONTENT_TITLE" hint="COM_TC_FORM_LBL_CONTENT_TITLE" />

<field name="version" required="true" class="validate-version" label="COM_TC_FORM_LBL_CONTENT_VERSION" description="COM_TC_FORM_DESC_CONTENT_VERSION" hint="COM_TC_FORM_LBL_CONTENT_VERSION"/>

<field name="client" required="true" id="client_id" class="validate-client" label="COM_TC_FORM_LBL_CONTENT_CLIENT" description="COM_TC_FORM_DESC_CONTENT_CLIENT" hint="COM_TC_FORM_LBL_CONTENT_CLIENT" />

<field name= "url_pattern" id="url_pattern_id" description= "COM_TC_FORM_LBL_CONTENT_URL_PATTERN_DESC" type= "subform" label= "COM_TC_FORM_LBL_CONTENT_URL_PATTERN" min= "1" max= "1000" formsource= "/administrator/components/com_tc/models/forms/url_pattern.xml" multiple= "true" buttons= "add,remove" layout="joomla.form.field.subform.repeatable-table" groupByFieldset="false" />
<field name="start_date"
type="calendar"
default="now"
showtime="true"
class="inputbox" format="%Y-%m-%d %H:%M:%S" required="true" label="COM_TC_FORM_LBL_CONTENT_START_DATE" description="COM_TC_FORM_DESC_CONTENT_START_DATE" hint="COM_TC_FORM_LBL_CONTENT_START_DATE" filter="user_utc"/>
<field name="content" type="editor" filter="raw" label="COM_TC_FORM_LBL_CONTENT_CONTENT" buttons="true" description="COM_TC_FORM_DESC_CONTENT_CONTENT" hint="COM_TC_FORM_LBL_CONTENT_CONTENT" />
<field name="global" type="radio" class="btn-group" id="global_id" label="COM_TC_FORM_LBL_CONTENT_GLOBAL" description="COM_TC_FORM_LBL_CONTENT_GLOBLA_DESC" default="0">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field name="groups" type="usergrouplist" multiple="true" default="0" label="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP" description="COM_TC_FORM_LBL_CONTENT_SELECT_USER_GROUP_DESC" />
<field name="is_blacklist" type="radio" class="btn-group" label="COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR" description="COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_DESC" default="1">
<option value="1">COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_YES</option>
<option value="0">COM_TC_FORM_LBL_CONTENT_USER_GROUP_BEHAVIOUR_NO</option>
</field>
<field name="enforce_delay_days" type="hidden" required="" label="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY" description="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY_DESC" hint="COM_TC_FORM_LBL_CONTENT_ENFORCE_DELAYS_DAY" />
<field name="created_by" type="hidden" default="0" filter="integer"/>
<field name="modified_by" type="hidden" default="0" filter="integer"/>
<field name="created_on" type="hidden" filter="unset" />
<field name="modified_on" type="hidden" filter="unset" />
</fieldset>
</form>
33 changes: 33 additions & 0 deletions src/administrator/models/forms/filter_contents.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field name="search" type="text" filter="string" label="JSEARCH_FILTER" description="JSEARCH_FILTER_DESC" hint="JSEARCH_FILTER" />
<field name="state" type="status" label="COM_TC_CONTENTS_FILTER_PUBLISHED" description="COM_TC_CONTENTS_FILTER_PUBLISHED_DESC" onchange="this.form.submit();">
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>
<field name="client" type="sql" query="SELECT DISTINCT (`client`) FROM `#__tc_content` ORDER BY client ASC" key_field="client" value_field="client" filter="safehtml" label="COM_TC_CONTENTS_CLIENT" description="COM_TC_CONTENTS_CLIENT_FILTER_DESC" onchange="this.form.submit();">
<option value="">COM_TC_CONTENTS_CLIENT_FILTER</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.tc_id DESC">
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.tc_id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.tc_id DESC">JGRID_HEADING_ID_DESC</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.version ASC">COM_TC_CONTENTS_VERSION_ASC</option>
<option value="a.version DESC">COM_TC_CONTENTS_VERSION_ASC</option>
<option value="a.client ASC">COM_TC_CONTENTS_CLIENT_ASC</option>
<option value="a.client DESC">COM_TC_CONTENTS_CLIENT_DES</option>
<option value="a.start_date DESC">COM_TC_CONTENTS_STARTDATE_ASC</option>
<option value="a.start_date DESC">COM_TC_CONTENTS_STARTDATE_DES</option>
</field>
<field name="limit" type="limitbox" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</form>
13 changes: 13 additions & 0 deletions src/administrator/models/forms/filter_usertcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<field name="search" type="text" filter="string" label="JSEARCH_FILTER" description="JSEARCH_FILTER_DESC" hint="JSEARCH_FILTER" />
<field name="client" type="sql" query="SELECT DISTINCT (`client`) FROM `#__tc_content` ORDER BY client ASC" key_field="client" value_field="client" filter="safehtml" label="COM_TC_CONTENTS_CLIENT" description="COM_TC_CONTENTS_CLIENT_FILTER_DESC" onchange="this.form.submit();">
<option value="">COM_TC_CONTENTS_CLIENT_FILTER</option>
</field>
<input type="hidden" name="form_submited" value="1" />
</fields>
<fields name="list">
<field name="limit" type="limitbox" class="input-mini" default="25" onchange="this.form.submit();" />
</fields>
</form>
20 changes: 7 additions & 13 deletions src/administrator/models/forms/url_pattern.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset>
<field name="id"
type="hidden"
label="" />
<field name="option"
type="text"
label="Option" />
<field name="view"
type="text"
label="View" />
</fieldset>
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset>
<field name="id" type="hidden" label="" />
<field name="option" type="text" label="Option" />
<field name="view" type="text" label="View" />
</fieldset>
</form>
10 changes: 10 additions & 0 deletions src/administrator/models/usertcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ protected function populateState($ordering = null, $direction = null)
$search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);

$client = $app->getUserStateFromRequest($this->context . '.filter.client', 'filter_client', '', 'string');
$this->setState('filter.client', $client);

// Load the parameters.
$params = JComponentHelper::getParams('com_tc');
$this->setState('params', $params);
Expand Down Expand Up @@ -139,6 +142,13 @@ protected function getListQuery()
}
}

$client = $this->getState('filter.client');

if (!empty($client))
{
$query->where($db->quoteName('c.client') . ' = ' . $db->quote($client));
}

// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
Expand Down
15 changes: 7 additions & 8 deletions src/administrator/tc.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.0" method="upgrade">
<name>com_tc</name>
<creationDate>2016-10-24</creationDate>
<copyright>2016 Parth Lawate</copyright>
<creationDate>10th Feb 2020</creationDate>
<copyright>Copyright (C) 2016 - 2020 Techjoomla. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<author>Parth Lawate</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://techjoomla.com</authorUrl>
<version>CVS: 1.0.0</version>
<description></description>

<author>Techjoomla</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://techjoomla.com/</authorUrl>
<version>1.0.1</version>
<description>This TC manager is used to assign TC's for any pages of site.</description>
<!-- The description is optional and defaults to the name -->
<description>COM_TC</description>
<scriptfile>script.tc.php</scriptfile>
Expand Down
2 changes: 1 addition & 1 deletion src/administrator/views/content/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function(data) {
echo $this->form->renderField('groups');
echo $this->form->renderField('is_blacklist');
echo $this->form->renderField('global');
echo $this->form->renderField('enforce_delay_days');
// echo $this->form->renderField('enforce_delay_days');
?>
</fieldset>
</div>
Expand Down
Loading

0 comments on commit 413eaf6

Please sign in to comment.