Skip to content

Commit 9692f18

Browse files
Merge pull request #265 from techjoomla/release-1.2.3
Release 1.2.3
2 parents eeaba35 + 8131057 commit 9692f18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1445
-1721
lines changed

src/components/com_tjucm/administrator/assets/css/tjucm.css

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,3 @@
1-
.icon-48-types {
2-
background-image: url(../images/l_types.png);
3-
padding-left:60px!important;
4-
}
5-
6-
.icon-48-type {
7-
background-image: url(../images/l_types.png);
8-
padding-left:60px!important;
9-
}
10-
11-
.color-box-types {
12-
float: left;width: 15px;height: 15px;margin-right: 5px;border: 1px solid rgba(0, 0, 0, .2);}
13-
14-
.icon-48-items {
15-
background-image: url(../images/l_items.png);
16-
padding-left:60px!important;
17-
}
18-
19-
.icon-48-item {
20-
background-image: url(../images/l_items.png);
21-
padding-left:60px!important;
22-
}
23-
24-
.color-box-items {
25-
float: left;width: 15px;height: 15px;margin-right: 5px;border: 1px solid rgba(0, 0, 0, .2);}
26-
27-
.other-filters{
28-
padding: 0 14px;
29-
}
30-
311
/* CSS for frontend*/
322
#item-form .radio input{
333
margin-left:5px !important;

src/components/com_tjucm/administrator/assets/js/tjucm_type.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/com_tjucm/administrator/classes/funlist.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/components/com_tjucm/administrator/houseKeeping/1.1.0/ucmSubformData.php

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,11 @@ public function migrate()
128128
// Save ucmSubForm records
129129
if (!empty($ucmSubFormDataSet))
130130
{
131-
$itemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel', array('ignore_request' => true));
132-
133131
// Set ucm type id to check permission in Item form model save() for logged-in user
134132
$ucmTypeId = $tjUcmModelType->getTypeId($ucmSubFormClient);
135-
$itemFormModel->setState('ucmType.id', $ucmTypeId);
136133

137134
// Call method to save ucmsubform data into new UCM data
138-
$subFormContentIds = $itemFormModel->saveUcmSubFormRecords($validData, $ucmSubFormDataSet);
135+
$subFormContentIds = $this->saveUcmSubFormRecords($validData, $ucmSubFormDataSet, $ucmTypeId);
139136

140137
// To update existing ucm subform field value from JSON to subform ucm type name
141138
if ($subFormContentIds)
@@ -163,4 +160,104 @@ public function migrate()
163160

164161
return $result;
165162
}
163+
164+
/**
165+
* Function to save ucmSubForm records
166+
*
167+
* @param ARRAY &$validData Parent record data
168+
* @param ARRAY $ucmSubFormDataSet ucmSubForm records data
169+
* @param ARRAY $ucmTypeId UCM Type Id
170+
*
171+
* @return ARRAY
172+
*/
173+
public function saveUcmSubFormRecords(&$validData, $ucmSubFormDataSet, $ucmTypeId)
174+
{
175+
$db = JFactory::getDbo();
176+
$subFormContentIds = array();
177+
$isNew = empty($validData['id']) ? 1 : 0;
178+
179+
// Delete removed subform details
180+
if (!$isNew)
181+
{
182+
$query = $db->getQuery(true);
183+
$query->select('id');
184+
$query->from($db->quoteName('#__tj_ucm_data'));
185+
$query->where($db->quoteName('parent_id') . '=' . $validData['id']);
186+
$db->setQuery($query);
187+
$oldSubFormContentIds = $db->loadColumn();
188+
}
189+
190+
JLoader::import('components.com_tjfields.tables.fieldsvalue', JPATH_ADMINISTRATOR);
191+
JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR);
192+
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models');
193+
$tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel');
194+
$itemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel', array('ignore_request' => true));
195+
$itemFormModel->setState('ucmType.id', $ucmTypeId);
196+
197+
if (!empty($ucmSubFormDataSet))
198+
{
199+
foreach ($ucmSubFormDataSet as $client => $ucmSubFormTypeData)
200+
{
201+
$validData['client'] = $client;
202+
$validData['type_id'] = $tjUcmModelType->getTypeId($client);
203+
$clientDetail = explode('.', $client);
204+
205+
// This is an extra field which is used to render the reference of the ucmsubform field on the form (used in case of edit)
206+
$ucmSubformContentIdFieldName = $clientDetail[0] . '_' . $clientDetail[1] . '_' . 'contentid';
207+
$count = 0;
208+
209+
foreach ($ucmSubFormTypeData as $ucmSubFormData)
210+
{
211+
$validData['id'] = isset($ucmSubFormData[$ucmSubformContentIdFieldName]) ? (int) $ucmSubFormData[$ucmSubformContentIdFieldName] : 0;
212+
213+
// Unset extra data
214+
$sfFieldName = $ucmSubFormData['ucmSubformFieldName'];
215+
unset($ucmSubFormData['ucmSubformFieldName']);
216+
$ucmSubformContentFieldElementId = 'jform[' . $sfFieldName . '][' . $sfFieldName . $count . '][' . $ucmSubformContentIdFieldName . ']';
217+
$count++;
218+
219+
if ($insertedId = $itemFormModel->save($validData, $ucmSubFormData))
220+
{
221+
$validData['id'] = $insertedId;
222+
$subFormContentIds[] = array('elementName' => $ucmSubformContentFieldElementId, 'content_id' => $insertedId);
223+
$ucmSubFormData[$ucmSubformContentIdFieldName] = $insertedId;
224+
225+
// Get field id of contentid field
226+
$fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db));
227+
$fieldTable->load(array('name' => $ucmSubformContentIdFieldName));
228+
229+
// Add-Update the value of content id field in the fields value table - start
230+
$fieldsValueTable = JTable::getInstance('Fieldsvalue', 'TjfieldsTable', array('dbo', $db));
231+
$fieldsValueTable->load(array('field_id' => $fieldTable->id, 'content_id' => $insertedId, 'client' => $validData['client']));
232+
233+
if (empty($fieldsValueTable->id))
234+
{
235+
$fieldsValueTable->field_id = $fieldTable->id;
236+
$fieldsValueTable->value = $fieldsValueTable->content_id = $insertedId;
237+
$fieldsValueTable->client = $validData['client'];
238+
}
239+
240+
$fieldsValueTable->user_id = JFactory::getUser()->id;
241+
$fieldsValueTable->store();
242+
243+
// Add-Update the value of content id field in the fields value table - end
244+
}
245+
}
246+
}
247+
}
248+
249+
// Delete removed ucmSubForm record from the form
250+
if (!empty($oldSubFormContentIds))
251+
{
252+
foreach ($oldSubFormContentIds as $oldSubFormContentId)
253+
{
254+
if (array_search($oldSubFormContentId, array_column($subFormContentIds, 'content_id')) === false)
255+
{
256+
$itemFormModel->delete($oldSubFormContentId);
257+
}
258+
}
259+
}
260+
261+
return $subFormContentIds;
262+
}
166263
}

0 commit comments

Comments
 (0)