Skip to content

Commit

Permalink
Merge branch 'release-1.2.4' into Bug#154975
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush-maherwal authored Jan 21, 2020
2 parents 45db73b + 211fba0 commit fe3a830
Show file tree
Hide file tree
Showing 26 changed files with 535 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* @package TJ-UCM
* @subpackage com_tjucm
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/

// No direct access
defined('_JEXEC') or die('Restricted access');

/**
* Migration file for TJ-UCM
*
* @since 1.2.4
*/
class TjHouseKeepingUpdateAlias extends TjModelHouseKeeping
{
public $title = "Update Types Alias";

public $description = 'Update UCM Types alias';

/**
* Subform migration script
*
* @return void
*
* @since 1.2.4
*/
public function migrate()
{
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables');
JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_menus/tables');

// TJ-Fields helper object
$tjfieldsHelper = new TjfieldsHelper;

$result = array();

try
{
// Get all the UCM types
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->qn('#__tj_ucm_types'));
$db->setQuery($query);
$ucmTypes = $db->loadObjectlist();

if (!empty($ucmTypes))
{
foreach ($ucmTypes as $ucmType)
{
$ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', $db));

// Remove white spaces in alias of UCM types
$updatedAlias = JFilterOutput::stringURLSafe($ucmTypeTable->alias);
$oldAlias = $ucmTypeTable->alias;
$ucmTypeTable->alias = $updatedAlias;
$ucmTypeTable->store();

$result['status'] = '';
$result['message'] = "Migration in progress";
}
}

// Get all the menus of UCM types
$query->from($db->quoteName('#__menu'));
$query->where(
$db->quoteName(link) . "=" . $db->quote('index.php?option=com_tjucm&view=itemform') .
"||" . $db->quoteName(link) . "=" . $db->quote('index.php?option=com_tjucm&view=items')
);
$db->setQuery($query);
$menuItems = $db->loadObjectlist();

if (!empty($menuItems))
{
foreach ($menuItems as $menuItem)
{
$menuItemTable = JTable::getInstance('Menu', 'MenusTable', array('dbo', $db));
$oldparams = json_decode($menuItemTable->params);

// Remove white spaces in alias of menus
$oldparams->ucm_type = JFilterOutput::stringURLSafe($oldparams->ucm_type);
$menuItemTable->params = json_encode($oldparams);
$menuItemTable->store();
$result['status'] = '';
$result['message'] = "Migration in progress";
}
}

$result['status'] = true;
$result['message'] = "Migration successful";
}
catch (Exception $e)
{
$result['err_code'] = '';
$result['status'] = false;
$result['message'] = $e->getMessage();
}
return $result;
}
}
5 changes: 5 additions & 0 deletions src/components/com_tjucm/administrator/models/forms/type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="bitrate_on" type="radio" class="btn-group" default="0" label="COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON" description="COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON" hint="COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON" showon="allow_auto_save:1">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="bitrate_seconds" type="number" filter="raw" label="COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS" description="COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS" hint="COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS" showon="bitrate_on:1"/>
<field name="layout" type="componentlayout" label="COM_TJUCM_FORM_LBL_TYPE_LAYOUT" description="COM_TJUCM_FORM_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="itemform" />
<field name="details_layout" type="componentlayout" label="COM_TJUCM_DETAILS_LBL_TYPE_LAYOUT" description="COM_TJUCM_DETAILS_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="item" />
<field name="list_layout" type="componentlayout" label="COM_TJUCM_LIST_LBL_TYPE_LAYOUT" description="COM_TJUCM_LIST_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="items" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/com_tjucm/administrator/models/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ public function save($data)
}

// Remove white spaces from alias if any
$data['alias'] = str_replace(" ", "_", trim($data['alias']));

//$data['alias'] = str_replace(" ", "_", trim($data['alias']));
$data['alias'] =JFilterOutput::stringURLSafe($data['alias']);
if (!empty($data['id']))
{
$field_group = $this->getGroupCount($data['unique_identifier']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,9 @@ COM_TJUCM_FIX_DATABASE="Fix Database"
; Added in version 1.2.0
COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN="Delete Own Item"
COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN_DESC="Allows users in the group to delete own items in this UCM type."

;Added in version 1.2.4
COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON="Enable timely autosave?"
COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item after specified interval of time. <b>Note:If you have used editor field in your UCM type then you should enable this configuration</b>"
COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Autosave Interval (seconds)"
COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type"
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ COM_TJUCM_TITLE_ITEMS="Items"
COM_TJUCM_TITLE_FORM_VIEW_ITEM="ItemForm"
COM_TJUCM_TITLE_FORM_VIEW_ITEM_DESC="Show a form to add or edit a Item"
COM_TJUCM_TITLE_LIST_VIEW_ITEMS="Items"
COM_TJUCM_TITLE_LIST_VIEW_ITEMS_DESC="Show a list of Items"
COM_TJUCM_TITLE_LIST_VIEW_ITEMS_DESC="Show a list of Items"
COM_TJUCM_TITLE_FORM_VIEW_ITEMFORM="One line one input"
COM_TJUCM_DEFAULT_TITLE_IN_OPTION="Two input in a row"
COM_TJUCM_GRID_TITLE_IN_OPTION="One input in a row"
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,4 @@ COM_TJUCM_CLICK_HERE="Click Here"
COM_TJUCM_ITEMS_IMPORTED_SCUUESSFULLY="%d record(s) imported successfully"
COM_TJUCM_ITEMS_IMPORT_REJECTED_RECORDS="%d invalid record(s) were not imported"
COM_TJUCM_ITEMS_NO_RECORDS_TO_IMPORT="No records found to import"
COM_TJUCM_ITEMS_IMPORTING_MSG="Please wait, Records are being imported..."
7 changes: 7 additions & 0 deletions src/components/com_tjucm/media/css/tjucm.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ margin-left:5px !important;
#item-form .chzn-container{
width:200px !important;
}

#item-form .field-calendar input{
display: inline !important;
}
#item-form textarea{
height: inherit !important;
}
2 changes: 2 additions & 0 deletions src/components/com_tjucm/media/js/core/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ com_tjucm.Services.Base = Class.extend({

config.contentType = typeof config.contentType != "undefined" ? config.contentType : 'application/x-www-form-urlencoded; charset=UTF-8';
config.processData = typeof config.processData != "undefined" ? config.processData : true;
config.async = typeof config.async != "undefined" ? config.async : true;

return jQuery.ajax({
type: "POST",
url: url,
data: data,
contentType: config.contentType,
processData: config.processData,
async: config.async,
headers: config.headers,
beforeSend: function () {
},
Expand Down
1 change: 1 addition & 0 deletions src/components/com_tjucm/media/js/services/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ com_tjucm.Services.Item = new (com_tjucm.Services.Base.extend({
create: function (ucmTypeData, callback){
this.config.processData = false;
this.config.contentType = false;
this.config.async = false;
this.post(this.createNewRecordUrl, ucmTypeData, this.config, callback);
},
saveFieldData: function (ucmFormData, callback) {
Expand Down
12 changes: 12 additions & 0 deletions src/components/com_tjucm/media/js/ui/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* confirmation message before item deletion */
jQuery(window).ready(function () {
jQuery('.delete-button').click(deleteItem);
});

function deleteItem()
{
if (!confirm(Joomla.JText._('COM_TJUCM_DELETE_MESSAGE')))
{
return false;
}
}
1 change: 1 addition & 0 deletions src/components/com_tjucm/media/js/ui/item.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 51 additions & 57 deletions src/components/com_tjucm/media/js/ui/itemform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jQuery(window).load(function()
{
var tjUcmAllowAutoSave = jQuery('#item-form #tjucm-autosave').val();

/*value of bitrate button*/
var tjUcmAllowBitrate = jQuery('#item-form #tjucm-bitrate').val();

/*value of bitrate seconds on button*/
var tjUcmBitrateSeconds = jQuery('#item-form #tjucm-bitrate_seconds').val();

/*Check if auto save is enabled for UCM type*/
if (tjUcmAllowAutoSave == 1)
{
Expand All @@ -43,53 +49,15 @@ jQuery(window).load(function()
}
});

var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce");

/* Get the value of editor fields*/
if (tjUcmTinyMCE != undefined)
/* Auto save form as per configured bit rate*/
if (tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmBitrateSeconds !== undefined)
{
jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){
if (jQuery("#item-form #jform_"+index).length)
{
var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html();
tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent;
}
else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default'))
{
var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']");

if (tjUcmSubFormEditorFields.length)
{
jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){
var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id');
var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html();
var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", "");
tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent;
});
}
}
});

/* Check after some time if the content of editor is changed and if so then save it in DB*/
setInterval(function () {
for (var key in tjUcmTinyMCEFieldIds) {
if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) {
var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html();

if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent)
{
var tjUcmTempFieldObj = jQuery("#jform_"+key);

if (tjUcmTempFieldObj.length)
{
tjUcmTempFieldObj.val(tjUcmEditorFieldContent);
tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent;
tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj);
}
}
}
}
},7000);
if (jQuery("#item-form #tjUcmSectionDraftSave").length >= 1)
{
setInterval(function(){
jQuery("#tjUcmSectionDraftSave").click();
}, tjUcmBitrateSeconds*1000);
}
}
}
}
Expand Down Expand Up @@ -625,7 +593,17 @@ var tjUcmItemForm = {
saveUcmFormData: function(){
/* Disable the action buttons before performing the action*/
jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true);
var tjUcmFormSubmitCallingButtonId = event.target.id;

if (event === undefined)
{
var tjUcmFormSubmitCallingButtonId = 'tjUcmSectionDraftSave';
var tjUcmBitrateAutoSaveCall = 1;
}
else
{
var tjUcmFormSubmitCallingButtonId = event.target.id;
}

var tjUcmSaveRecordAsDraft = 1;

if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionFinalSave')
Expand Down Expand Up @@ -657,11 +635,16 @@ var tjUcmItemForm = {
tjUcmSaveRecordAsDraft = 0;
}

/* For AJAX save need to assign values to the editor field containers*/
/* For AJAX save need to assign values to the editor field containers of tinyMCE editor*/
jQuery("#item-form .toggle-editor a").each(function(index) {
this.click();
});

/* For AJAX save need to assign values to the editor field containers of JCE editor*/
jQuery("#item-form .wf-editor-toggle").each(function(index) {
this.click();
});

tjUcmItemForm.getUcmParentRecordId(tjUcmSaveRecordAsDraft, function (){
var tjUcmForm = document.getElementById('item-form');
var tjUcmItemFormData = new FormData(tjUcmForm);
Expand All @@ -688,23 +671,34 @@ var tjUcmItemForm = {
}

jQuery('input[type="checkbox"]').each(function (){
if (jQuery(this).prop('checked') == true)
{
tjUcmItemFormData.append(jQuery(this).attr('name'), 1);
}
else
{
tjUcmItemFormData.append(jQuery(this).attr('name'), 0);
}
if (jQuery(this).prop('checked') == true)
{
tjUcmItemFormData.append(jQuery(this).attr('name'), 1);
}
else
{
tjUcmItemFormData.append(jQuery(this).attr('name'), 0);
}
});

/* Do not show draft save msg if the save is triggered as per bitrate config*/
if (tjUcmBitrateAutoSaveCall !== undefined)
{
tjUcmItemFormData.append('showDraftMessage', 0);
}

com_tjucm.Services.Item.saveFormData(tjUcmItemFormData, tjUcmItemForm.afterDataSave);
});

/* Once data is assigned to the textarea toggle the editors*/
/* Once data is assigned to the textarea toggle the tinyMCE editors*/
jQuery("#item-form .toggle-editor a").each(function(index) {
this.click();
});

/* Once data is assigned to the textarea toggle the Jce editors*/
jQuery("#item-form .wf-editor-toggle").each(function(index) {
this.click();
});
},
saveSectionData: function (tabId){
/* Disable the action buttons before performing the action*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/com_tjucm/media/js/ui/itemform.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit fe3a830

Please sign in to comment.