Refactored the compiler list view body builder, in preparation of the relation fields. Added more options to the relation admin fields. gh-287

This commit is contained in:
2018-05-24 15:56:56 +02:00
parent 84b683182a
commit fef3460772
56 changed files with 1004 additions and 908 deletions

View File

@ -677,5 +677,4 @@ class Compiler extends Infusion
// any help to improve this is welcome...
}
}

View File

@ -487,6 +487,20 @@ class Get
*/
public $catOtherName = array();
/**
* The field relations values
*
* @var array
*/
public $fieldRelations = array();
/**
* The list join fields
*
* @var array
*/
public $listJoinBuilder = array();
/**
* The linked admin view tabs
*
@ -1340,18 +1354,21 @@ class Get
'b.addfields',
'b.id',
'c.addconditions',
'c.id'
'c.id',
'r.addrelations'
), array(
'addfields',
'addfields_id',
'addconditions',
'addconditions_id'
'addconditions_id',
'addrelations'
)
)
);
$query->from('#__componentbuilder_admin_view AS a');
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_admin_fields', 'b') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('b.admin_view') . ')');
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_admin_fields_conditions', 'c') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('c.admin_view') . ')');
$query->join('LEFT', $this->db->quoteName('#__componentbuilder_admin_fields_relations', 'r') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('r.admin_view') . ')');
$query->where($this->db->quoteName('a.id') . ' = ' . (int) $id);
// Reset the query using our newly populated query object.
@ -1624,7 +1641,7 @@ class Get
$conditionValue['match_type'] = $type;
$conditionValue['match_xml'] = $fieldValue['settings']->xml;
// if custom field load field being extended
if (!ComponentbuilderHelper::typeField($type))
if (!ComponentbuilderHelper::fieldCheck($type))
{
$conditionValue['match_extends'] = ComponentbuilderHelper::getBetween($fieldValue['settings']->xml, 'extends="', '"');
}
@ -1642,6 +1659,35 @@ class Get
}
}
unset($view->addconditions);
// prep the buckets
$this->fieldRelations[$name_list] = array();
$this->listJoinBuilder[$name_list] = array();
// set the relations
$view->addrelations = (isset($view->addrelations) && ComponentbuilderHelper::checkJson($view->addrelations)) ? json_decode($view->addrelations, true) : null;
if (ComponentbuilderHelper::checkArray($view->addrelations))
{
foreach ($view->addrelations as $nr => $relationsValue)
{
// only add if list view field is selected and joind fields are set
if (isset($relationsValue['listfield']) &&
is_numeric($relationsValue['listfield']) &&
$relationsValue['listfield'] > 0 &&
isset($relationsValue['joinfields']) &&
ComponentbuilderHelper::checkArray($relationsValue['joinfields']))
{
// load the field relations
$this->fieldRelations[$name_list][(int) $relationsValue['listfield']] = $relationsValue;
// load the list joints
foreach ($relationsValue['joinfields'] as $join)
{
$this->listJoinBuilder[$name_list][(int) $join] = (int) $join;
}
}
}
}
unset($view->addrelations);
// set linked views
$this->linkedAdminViews[$name_single] = null;
$view->addlinked_views = (isset($view->addlinked_views) && ComponentbuilderHelper::checkJson($view->addlinked_views)) ? json_decode($view->addlinked_views, true) : null;

View File

@ -1075,7 +1075,7 @@ class Fields extends Structure
// set the array of field names
$this->setFieldsNames($view_name_single, $fieldAttributes['name']);
if ($this->defaultField($typeName, 'option'))
if (ComponentbuilderHelper::fieldCheck($typeName, 'option'))
{
//reset options array
$optionArray = array();
@ -1087,7 +1087,7 @@ class Fields extends Structure
$this->setBuilders($langLabel, $langView, $view_name_single, $view_name_list, $name, $view, $field, $typeName, $multiple, false, $optionArray);
}
}
elseif ($this->defaultField($typeName, 'plain'))
elseif (ComponentbuilderHelper::fieldCheck($typeName, 'plain'))
{
if ($build)
{
@ -1097,7 +1097,7 @@ class Fields extends Structure
// now add to the field set
$dynamicField = $this->setField('plain', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray);
}
elseif ($this->defaultField($typeName, 'spacer'))
elseif (ComponentbuilderHelper::fieldCheck($typeName, 'spacer'))
{
if ($build)
{
@ -1117,7 +1117,7 @@ class Fields extends Structure
// now add to the field set
$dynamicField = $this->setField('spacer', $fieldAttributes, $name, $typeName, $langView, $view_name_single, $view_name_list, $placeholders, $optionArray);
}
elseif ($this->defaultField($typeName, 'special'))
elseif (ComponentbuilderHelper::fieldCheck($typeName, 'special'))
{
// set the repeatable field or subform field
if ($typeName === 'repeatable' || $typeName === 'subform')
@ -1378,12 +1378,12 @@ class Fields extends Structure
{
//reset options array
$r_optionArray = array();
if ($this->defaultField($r_typeName, 'option'))
if (ComponentbuilderHelper::fieldCheck($r_typeName, 'option'))
{
// now add to the field set
$field .= $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
}
elseif ($this->defaultField($r_typeName, 'plain'))
elseif (ComponentbuilderHelper::fieldCheck($r_typeName, 'plain'))
{
// now add to the field set
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
@ -1465,12 +1465,12 @@ class Fields extends Structure
{
//reset options array
$r_optionArray = array();
if ($this->defaultField($r_typeName, 'option'))
if (ComponentbuilderHelper::fieldCheck($r_typeName, 'option'))
{
// now add to the field set
$field .= $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
}
elseif ($this->defaultField($r_typeName, 'plain'))
elseif (ComponentbuilderHelper::fieldCheck($r_typeName, 'plain'))
{
// now add to the field set
$field .= $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray, null, $r_taber);
@ -1715,12 +1715,12 @@ class Fields extends Structure
{
//reset options array
$r_optionArray = array();
if ($this->defaultField($r_typeName, 'option'))
if (ComponentbuilderHelper::fieldCheck($r_typeName, 'option'))
{
// now add to the field set
ComponentbuilderHelper::xmlAppend($fieldSetXML, $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray));
}
elseif ($this->defaultField($r_typeName, 'plain'))
elseif (ComponentbuilderHelper::fieldCheck($r_typeName, 'plain'))
{
// now add to the field set
ComponentbuilderHelper::xmlAppend($fieldSetXML, $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray));
@ -1812,12 +1812,12 @@ class Fields extends Structure
{
//reset options array
$r_optionArray = array();
if ($this->defaultField($r_typeName, 'option'))
if (ComponentbuilderHelper::fieldCheck($r_typeName, 'option'))
{
// now add to the field set
ComponentbuilderHelper::xmlAppend($form, $this->setField('option', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray));
}
elseif ($this->defaultField($r_typeName, 'plain'))
elseif (ComponentbuilderHelper::fieldCheck($r_typeName, 'plain'))
{
// now add to the field set
ComponentbuilderHelper::xmlAppend($form, $this->setField('plain', $r_fieldValues, $r_name, $r_typeName, $langView, $view_name_single, $view_name_list, $placeholders, $r_optionArray));
@ -2049,7 +2049,7 @@ class Fields extends Structure
$fieldAttributes = array();
$setCustom = false;
// setup joomla default fields
if (!$this->defaultField($typeName))
if (!ComponentbuilderHelper::fieldCheck($typeName))
{
$fieldAttributes['custom'] = array();
$setCustom = true;
@ -2399,6 +2399,10 @@ class Fields extends Structure
$this->dbKeys[$view_name_single][] = $name;
}
}
// set list switch
$listSwitch = (isset($field['list']) && $field['list'] == 1);
// set list join
$listJoin = (isset($this->listJoinBuilder[$view_name_list][(int) $field['field']]));
// add history to this view
if (isset($view['history']) && $view['history'])
{
@ -2443,22 +2447,44 @@ class Fields extends Structure
}
}
// build the list values
if ((isset($field['list']) && $field['list'] == 1) && $typeName != 'repeatable' && $typeName != 'subform')
if (($listSwitch || $listJoin) && $typeName != 'repeatable' && $typeName != 'subform')
{
// load to list builder
$this->listBuilder[$view_name_list][] = array(
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'title' => (isset($field['title']) && $field['title']) ? true : false,
'alias' => (isset($field['alias']) && $field['alias']) ? true : false,
'link' => (isset($field['link']) && $field['link']) ? true : false,
'sort' => (isset($field['sort']) && $field['sort']) ? true : false,
'custom' => $custom,
'multiple' => $multiple,
'options' => $options);
$this->customBuilderList[$view_name_list][] = $name;
if ($listSwitch)
{
$this->listBuilder[$view_name_list][] = array(
'id' => (int) $field['field'],
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'title' => (isset($field['title']) && $field['title']) ? true : false,
'alias' => (isset($field['alias']) && $field['alias']) ? true : false,
'link' => (isset($field['link']) && $field['link']) ? true : false,
'sort' => (isset($field['sort']) && $field['sort']) ? true : false,
'custom' => $custom,
'multiple' => $multiple,
'options' => $options);
}
// load the list join builder
elseif ($listJoin)
{
$this->listJoinBuilder[$view_name_list][(int) $field['field']] = array(
'type' => $typeName,
'code' => $name,
'lang' => $listLangName,
'title' => (isset($field['title']) && $field['title']) ? true : false,
'alias' => (isset($field['alias']) && $field['alias']) ? true : false,
'link' => (isset($field['link']) && $field['link']) ? true : false,
'sort' => (isset($field['sort']) && $field['sort']) ? true : false,
'custom' => $custom,
'multiple' => $multiple,
'options' => $options);
}
// build custom builder list
if ($listSwitch || $listJoin)
{
$this->customBuilderList[$view_name_list][] = $name;
}
}
// set the hidden field of this view
if ($typeName === 'hidden')
@ -2601,7 +2627,7 @@ class Fields extends Structure
}
// load the json list display fix
if ((isset($field['list']) && $field['list'] == 1) && $typeName != 'repeatable' && $typeName != 'subform')
if (($listSwitch || $listJoin) && $typeName != 'repeatable' && $typeName != 'subform')
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -2636,12 +2662,12 @@ class Fields extends Structure
// check if field should be added to uikit
$this->buildSiteFieldData($view_name_single, $name, 'uikit', $typeName);
// load the selection translation fix
if (ComponentbuilderHelper::checkArray($options) && (isset($field['list']) && $field['list'] == 1) && $typeName != 'repeatable' && $typeName != 'subform')
if (ComponentbuilderHelper::checkArray($options) && ($listSwitch || $listJoin) && $typeName != 'repeatable' && $typeName != 'subform')
{
$this->selectionTranslationFixBuilder[$view_name_list][$name] = $options;
}
// build the sort values
if ($dbSwitch && (isset($field['sort']) && $field['sort'] == 1) && (isset($field['list']) && $field['list'] == 1) && (!$multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform'))
if ($dbSwitch && (isset($field['sort']) && $field['sort'] == 1) && ($listSwitch || $listJoin) && (!$multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform'))
{
$this->sortBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'custom' => $custom, 'options' => $options);
}
@ -2652,7 +2678,7 @@ class Fields extends Structure
$this->searchBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'custom' => $custom, 'list' => $_list);
}
// build the filter values
if ($dbSwitch && (isset($field['filter']) && $field['filter'] == 1) && (isset($field['list']) && $field['list'] == 1) && (!$multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform'))
if ($dbSwitch && (isset($field['filter']) && $field['filter'] == 1) && ($listSwitch || $listJoin) && (!$multiple && $typeName != 'checkbox' && $typeName != 'checkboxes' && $typeName != 'repeatable' && $typeName != 'subform'))
{
$this->filterBuilder[$view_name_list][] = array('type' => $typeName, 'code' => $name, 'lang' => $listLangName, 'database' => $view_name_single, 'function' => ComponentbuilderHelper::safeString($name, 'F'), 'custom' => $custom, 'options' => $options);
}
@ -2993,58 +3019,6 @@ class Fields extends Structure
return '';
}
/**
* default Fields
*
* @param string $type The field type
* @param boolean $option The field grouping
*
* @return boolean if the field was found
*
*/
public function defaultField($type, $option = 'default')
{
// list of default fields
// https://docs.joomla.org/Form_field
$defaults = array(
'default' => array(
'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox',
'checkboxes', 'color', 'combo', 'componentlayout', 'contentlanguage', 'editor',
'chromestyle', 'contenttype', 'databaseconnection', 'editors', 'email', 'file',
'filelist', 'folderlist', 'groupedlist', 'hidden', 'file', 'headertag', 'helpsite',
'imagelist', 'integer', 'language', 'list', 'media', 'menu', 'note', 'number', 'password',
'plugins', 'radio', 'repeatable', 'range', 'rules', 'subform', 'sessionhandler', 'spacer', 'sql', 'tag',
'tel', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', 'moduletag',
'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
),
'plain' => array(
'accesslevel', 'checkbox', 'cachehandler', 'calendar', 'category', 'chromestyle', 'color',
'contenttype', 'combo', 'componentlayout', 'databaseconnection', 'editor', 'editors',
'email', 'file', 'filelist', 'folderlist', 'headertag', 'helpsite',
'hidden', 'imagelist', 'integer', 'language', 'media', 'menu',
'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules',
'sessionhandler', 'tag', 'tel', 'text', 'textarea',
'timezone', 'url', 'user', 'usergroup'
),
'spacer' => array(
'note', 'spacer'
),
'option' => array(
'plugins', 'checkboxes', 'contentlanguage', 'list', 'radio', 'sql'
),
'special' => array(
'contentlanguage', 'groupedlist', 'moduleposition', 'plugin',
'repeatable', 'templatestyle', 'subform'
)
);
if (in_array($type, $defaults[$option]))
{
return true;
}
return false;
}
/**
* xmlPrettyPrint
*

View File

@ -6327,6 +6327,7 @@ class Interpretation extends Fields
$Helper = $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . 'Helper';
// setup correct core target
$coreLoad = false;
$core = null;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
@ -6409,199 +6410,44 @@ class Interpretation extends Fields
// start adding the dynamic
foreach ($this->listBuilder[$viewName_list] as $item)
{
$checkoutTriger = false;
if (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && isset($item['custom']['table']) && ComponentbuilderHelper::checkString($item['custom']['table']))
// set some defaults
$customAdminViewButtons = '';
// set the item default class
$itemClass = 'hidden-phone';
// get list item code
$itemCode = $this->getListItemCode($item, $viewName_list, $doNotEscape);
// is this a linked item
if ($item['link'] || (ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user'))
{
$item['id'] = $item['code'];
if (!$item['multiple'])
{
$item['code'] = $item['code'] . '_' . $item['custom']['text'];
}
}
// check if translated value is used
if (isset($this->selectionTranslationFixBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->selectionTranslationFixBuilder[$viewName_list]) && array_key_exists($item['code'], $this->selectionTranslationFixBuilder[$viewName_list]))
{
$itemCode = '<?php echo JText:' . ':_($item->' . $item['code'] . '); ?>';
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['text'] === 'user')
{
$itemCode = '<?php echo JFactory::getUser((int)$item->' . $item['code'] . ')->name; ?>';
}
elseif ($doNotEscape)
{
if (in_array($item['code'], $this->doNotEscape[$viewName_list]))
{
$itemCode = '<?php echo $item->' . $item['code'] . '; ?>';
}
else
{
$itemCode = '<?php echo $this->escape($item->' . $item['code'] . '); ?>';
}
// set some defaults
$checkoutTriger = false;
// set the item default class
$itemClass = 'nowrap';
// get list item link
$itemLink = $this->getListItemLink($item, $checkoutTriger, $viewName_single, $viewName_list);
// get list item link autority
$itemLinkAutority = $this->getListItemLinkAutority($item, $viewName_single, $viewName_list, $coreLoad, $core);
// set item row
$itemRow = $this->getListItemLinkRow($itemCode, $itemLink, $itemLinkAutority, $viewName_list, $checkoutTriger);
}
else
{
$itemCode = '<?php echo $this->escape($item->' . $item['code'] . '); ?>';
// set item row
$itemRow = PHP_EOL . "\t\t\t<?php echo " . $itemCode . "; ?>";
}
if ($item['link'])
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :)
{
// allways rest custom links
$customAdminView = '';
// if to be linked
if ($item['type'] === 'category' && !$item['title'])
{
$otherViews = $this->catCodeBuilder[$viewName_single]['views'];
// category and linked
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$this->user->authorise('core.edit', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $otherViews . ".category.' . (int)\$item->" . $item['code'] . ")): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->' . $item['code'] . '; ?>&extension=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '.' . $otherViews . '"><?php echo $this->escape($item->category_title); ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$this->escape(\$item->category_title); ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
elseif ($item['type'] === 'user' && !$item['title'])
{
// user and linked
$body .= PHP_EOL . "\t\t<?php \$" . $item['code'] . "User = JFactory::getUser(\$item->" . $item['code'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$this->user->authorise('core.edit', 'com_users')): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['code'] . ' ?>"><?php echo $' . $item['code'] . 'User->name; ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$" . $item['code'] . "User->name; ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
else
{
$add = true;
if (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] != 'user' && !$item['title'])
{
// link to that item instead
$link = 'index.php?option=' . $item['custom']['component'] . '&view=' . $item['custom']['views'] . '&task=' . $item['custom']['view'] . '.edit&id=<?php echo $item->' . $item['id'] . '; ?>&ref=' . $viewName_list;
$coreLoadLink = false;
if (isset($this->permissionCore[$item['custom']['view']]))
{
$coreLink = $this->permissionCore[$item['custom']['view']];
$coreLoadLink = true;
}
// check if the item has permissions.
if ($coreLoadLink && (isset($coreLink['core.edit']) && isset($this->permissionBuilder[$coreLink['core.edit']])) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$coreLink['core.edit']]) && in_array($item['custom']['view'], $this->permissionBuilder[$coreLink['core.edit']]))
{
$accessCheck = "\$this->user->authorise('" . $coreLink['core.edit'] . "', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $item['custom']['view'] . ".' . (int)\$item->" . $item['id'] . ")";
}
else
{
$accessCheck = "\$this->user->authorise('core.edit', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $item['custom']['view'] . ".' . (int)\$item->" . $item['id'] . ")";
}
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user' && !$item['title'])
{
// user and linked
$body .= PHP_EOL . "\t\t<?php \$" . $item['id'] . " = JFactory::getUser(\$item->" . $item['id'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$this->user->authorise('core.edit', 'com_users')): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['id'] . ' ?>"><?php echo $' . $item['id'] . '->name; ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$" . $item['id'] . "->name; ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
$add = false;
}
else
{
// start building the links
$link = '<?php echo $edit; ?>&id=<?php echo $item->id; ?>';
// check if custom links should be added to this list views
if (isset($this->customAdminViewListLink[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customAdminViewListLink[$viewName_list]) && $firstTimeBeingAdded)
{
// make sure the custom links are only added once
$firstTimeBeingAdded = false;
// start building the links
$customAdminView = PHP_EOL . "\t\t\t" . '<div class="btn-group">';
foreach ($this->customAdminViewListLink[$viewName_list] as $customLinkView)
{
$customAdminView .= PHP_EOL . "\t\t\t<?php if (\$canDo->get('" . $customLinkView['link'] . ".access')): ?>";
$customAdminView .= PHP_EOL . "\t\t\t\t" . '<a class="hasTooltip btn btn-mini" href="index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $customLinkView['link'] . '&id=<?php echo $item->id; ?>" title="<?php echo JText:' . ':_(' . "'COM_" . $this->fileContentStatic[$this->hhh . 'COMPONENT' . $this->hhh] . '_' . $customLinkView['NAME'] . "'" . '); ?>" ><span class="icon-' . $customLinkView['icon'] . '"></span></a>';
$customAdminView .= PHP_EOL . "\t\t\t<?php else: ?>";
$customAdminView .= PHP_EOL . "\t\t\t\t" . '<a class="hasTooltip btn btn-mini disabled" href="#" title="<?php echo JText:' . ':_(' . "'COM_" . $this->fileContentStatic[$this->hhh . 'COMPONENT' . $this->hhh] . '_' . $customLinkView['NAME'] . "'" . '); ?>"><span class="icon-' . $customLinkView['icon'] . '"></span></a>';
$customAdminView .= PHP_EOL . "\t\t\t<?php endif; ?>";
}
$customAdminView .= PHP_EOL . "\t\t\t" . '</div>';
}
// check if the item has permissions.
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit']]))
{
// set permissions.
$accessCheck = "\$canDo->get('" . $core['core.edit'] . "')";
}
else
{
// set permissions.
$accessCheck = "\$canDo->get('core.edit')";
}
// triger the checked out script to be added
$checkoutTriger = true;
}
if ($add)
{
// set as linked
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (" . $accessCheck . "): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<div class="name">' . PHP_EOL . "\t\t\t\t\t" . '<a href="' . $link . '">' . $itemCode . '</a>';
if ($checkoutTriger)
{
$body .= PHP_EOL . "\t\t\t\t\t<?php if (\$item->checked_out): ?>";
$body .= PHP_EOL . "\t\t\t\t\t\t<?php echo JHtml::_('jgrid.checkedout', \$i, \$userChkOut->name, \$item->checked_out_time, '" . $viewName_list . ".', \$canCheckin); ?>";
$body .= PHP_EOL . "\t\t\t\t\t<?php endif; ?>";
}
$body .= PHP_EOL . "\t\t\t\t" . '</div>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<div class="name">' . $itemCode . '</div>';
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= $customAdminView;
$body .= PHP_EOL . "\t\t</td>";
}
}
}
else
{
if ($item['type'] === 'category')
{
$body .= PHP_EOL . "\t\t<td class=\"" . $this->setListFieldClass($item['code'], $viewName_list, 'hidden-phone') . "\">";
$body .= PHP_EOL . "\t\t\t<?php echo \$this->escape(\$item->category_title); ?>";
$body .= PHP_EOL . "\t\t</td>";
}
elseif (ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user')
{
// custom user and linked
$body .= PHP_EOL . "\t\t<?php \$" . $item['code'] . " = JFactory::getUser(\$item->" . $item['id'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap hidden-phone') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$this->user->authorise('core.edit', 'com_users')): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['id'] . ' ?>"><?php echo $' . $item['code'] . '->name; ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$" . $item['code'] . "->name; ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
elseif ($item['type'] === 'user')
{
// user name only
$body .= PHP_EOL . "\t\t<?php \$" . $item['code'] . "User = JFactory::getUser(\$item->" . $item['code'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php echo \$" . $item['code'] . "User->name; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
else
{
// normal not linked
$body .= PHP_EOL . "\t\t<td class=\"" . $this->setListFieldClass($item['code'], $viewName_list, 'hidden-phone') . "\">";
$body .= PHP_EOL . "\t\t\t" . $itemCode;
$body .= PHP_EOL . "\t\t</td>";
}
// get custom admin view buttons
$customAdminViewButtons = $this->getCustomAdminViewButtons($item, $viewName_single, $viewName_list, $coreLoad);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
}
// add row to body
$body .= PHP_EOL . "\t\t<td class=\"" . $this->setListFieldClass($item['code'], $viewName_list, $itemClass) . "\">";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . "\t\t</td>";
}
// add the defaults
if (!isset($this->fieldsNames[$viewName_single]['published']))
@ -6644,6 +6490,192 @@ class Interpretation extends Fields
return '';
}
protected function getListItemLinkRow($itemCode, $itemLink, $itemLinkAutority, $viewName_list, $checkoutTriger, $class = true)
{
// add class
$tab = '';
if ($class)
{
$link .= PHP_EOL . "\t\t\t" . '<div class="name">';
$tab = "\t";
}
// the link logic
$link .= PHP_EOL . $tab . "\t\t\t<?php if (" . $itemLinkAutority . "): ?>";
$link .= PHP_EOL . $tab . "\t\t\t\t" . '<a href="' . $itemLink . '"><?php echo ' . $itemCode . '; ?></a>';
if ($checkoutTriger)
{
$link .= PHP_EOL . $tab . "\t\t\t\t<?php if (\$item->checked_out): ?>";
$link .= PHP_EOL . $tab . "\t\t\t\t\t<?php echo JHtml::_('jgrid.checkedout', \$i, \$userChkOut->name, \$item->checked_out_time, '" . $viewName_list . ".', \$canCheckin); ?>";
$link .= PHP_EOL . $tab . "\t\t\t\t<?php endif; ?>";
}
$link .= PHP_EOL . $tab . "\t\t\t<?php else: ?>";
$link .= PHP_EOL . $tab . "\t\t\t\t<?php echo " . $itemCode . "; ?>";
$link .= PHP_EOL . $tab . "\t\t\t<?php endif; ?>";
// add class
if ($class)
{
$link .= PHP_EOL . "\t\t\t</div>";
}
// return the link logic
return $link;
}
protected function getCustomAdminViewButtons($viewName_list, $ref = '')
{
$customAdminViewButton = '';
// check if custom links should be added to this list views
if (isset($this->customAdminViewListLink[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customAdminViewListLink[$viewName_list]))
{
// start building the links
$customAdminViewButton .= PHP_EOL . "\t\t\t" . '<div class="btn-group">';
foreach ($this->customAdminViewListLink[$viewName_list] as $customLinkView)
{
$customAdminViewButton .= PHP_EOL . "\t\t\t<?php if (\$canDo->get('" . $customLinkView['link'] . ".access')): ?>";
$customAdminViewButton .= PHP_EOL . "\t\t\t\t" . '<a class="hasTooltip btn btn-mini" href="index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $customLinkView['link'] . '&id=<?php echo $item->id; ?>' . $ref . '" title="<?php echo JText:' . ':_(' . "'COM_" . $this->fileContentStatic[$this->hhh . 'COMPONENT' . $this->hhh] . '_' . $customLinkView['NAME'] . "'" . '); ?>" ><span class="icon-' . $customLinkView['icon'] . '"></span></a>';
$customAdminViewButton .= PHP_EOL . "\t\t\t<?php else: ?>";
$customAdminViewButton .= PHP_EOL . "\t\t\t\t" . '<a class="hasTooltip btn btn-mini disabled" href="#" title="<?php echo JText:' . ':_(' . "'COM_" . $this->fileContentStatic[$this->hhh . 'COMPONENT' . $this->hhh] . '_' . $customLinkView['NAME'] . "'" . '); ?>"><span class="icon-' . $customLinkView['icon'] . '"></span></a>';
$customAdminViewButton .= PHP_EOL . "\t\t\t<?php endif; ?>";
}
$customAdminViewButton .= PHP_EOL . "\t\t\t" . '</div>';
}
return $customAdminViewButton;
}
protected function getListItemCode(&$item, $viewName_list, $doNotEscape, $escape = '$this->escape')
{
// first update the code id needed
if (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && isset($item['custom']['table']) && ComponentbuilderHelper::checkString($item['custom']['table']))
{
$item['id_code'] = $item['code'];
if (!$item['multiple'])
{
$item['code'] = $item['code'] . '_' . $item['custom']['text'];
}
}
// check if category
if ($item['type'] === 'category' && !$item['title'])
{
return $escape . '($item->category_title)';
}
// check if user
elseif ($item['type'] === 'user')
{
return 'JFactory::getUser((int)$item->' . $item['code'] . ')->name';
}
// check if custom user
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user' && isset($item['id_code']))
{
return 'JFactory::getUser((int)$item->' . $item['id_code'] . ')->name';
}
// check if translated value is used
elseif (isset($this->selectionTranslationFixBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->selectionTranslationFixBuilder[$viewName_list]) && array_key_exists($item['code'], $this->selectionTranslationFixBuilder[$viewName_list]))
{
return 'JText:' . ':_($item->' . $item['code'] . ')';
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['text'] === 'user')
{
return 'JFactory::getUser((int)$item->' . $item['code'] . ')->name';
}
elseif ($doNotEscape)
{
if (in_array($item['code'], $this->doNotEscape[$viewName_list]))
{
return '$item->' . $item['code'];
}
}
// default
return $escape . '($item->' . $item['code'] . ')';
}
protected function getListItemLink($item, &$checkoutTriger, $viewName_single, $viewName_list, $ref = null)
{
// set referal if not set
$referal = '';
if (!$ref)
{
$ref = '&ref=' . $viewName_list;
}
// in linked tab/view so must add ref to default
else
{
$referal = $ref;
}
// if to be linked
if ($item['type'] === 'category' && !$item['title'])
{
// get the other view
$otherViews = $this->catCodeBuilder[$viewName_single]['views'];
// return the link to category
return 'index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->' . $item['code'] . '; ?>&extension=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '.' . $otherViews;
}
elseif ($item['type'] === 'user' && !$item['title'])
{
// return user link
return 'index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['code'] . ' ?>';
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] != 'user' && !$item['title'] && isset($item['id_code']))
{
// link to that linked item
return 'index.php?option=' . $item['custom']['component'] . '&view=' . $item['custom']['views'] . '&task=' . $item['custom']['view'] . '.edit&id=<?php echo $item->' . $item['id_code'] . '; ?>' . $ref;
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user' && !$item['title'] && isset($item['id_code']))
{
// return user link
return 'index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['id_code'] . ' ?>';
}
// make sure to triger the checkout
$checkoutTriger = true;
// basic default item link
return '<?php echo $edit; ?>&id=<?php echo $item->id; ?>'.$referal;
}
protected function getListItemLinkAutority($item, $viewName_single, $viewName_list, $coreLoad, $core, $user = '$this->user')
{
// if to be linked
if ($item['type'] === 'category' && !$item['title'])
{
// get the other view
$otherViews = $this->catCodeBuilder[$viewName_single]['views'];
// return the autority to category
return $user . "->authorise('core.edit', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $otherViews . ".category.' . (int)\$item->" . $item['code'] . ")";
}
elseif ($item['type'] === 'user' && !$item['title'])
{
// return user autority
return $user . "->authorise('core.edit', 'com_users')";
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] != 'user' && !$item['title'] && isset($item['id_code']))
{
// link to that linked item
$coreLoadLink = false;
if (isset($this->permissionCore[$item['custom']['view']]))
{
$coreLink = $this->permissionCore[$item['custom']['view']];
$coreLoadLink = true;
}
// check if the item has permissions.
if ($coreLoadLink && (isset($coreLink['core.edit']) && isset($this->permissionBuilder[$coreLink['core.edit']])) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$coreLink['core.edit']]) && in_array($item['custom']['view'], $this->permissionBuilder[$coreLink['core.edit']]))
{
return $user . "->authorise('" . $coreLink['core.edit'] . "', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $item['custom']['view'] . ".' . (int)\$item->" . $item['id_code'] . ")";
}
// return default for this external item
return $user . "->authorise('core.edit', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $item['custom']['view'] . ".' . (int)\$item->" . $item['id_code'] . ")";
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user' && !$item['title'] && isset($item['id_code']))
{
// return user link
return $user . "->authorise('core.edit', 'com_users')";
}
// check if the item has custom permissions.
elseif ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit']]))
{
// set permissions.
return "\$canDo->get('" . $core['core.edit'] . "')";
}
// set core permissions.
return "\$canDo->get('core.edit')";
}
protected function setListFieldClass($name, $listViewName, $default = '')
{
return (isset($this->listFieldClass[$listViewName]) && isset($this->listFieldClass[$listViewName][$name])) ? $this->listFieldClass[$listViewName][$name] : $default;
@ -7548,6 +7580,7 @@ class Interpretation extends Fields
$firstTimeBeingAdded = true;
// setup correct core target
$coreLoad = false;
$core = null;
if (isset($this->permissionCore[$viewName_single]))
{
$core = $this->permissionCore[$viewName_single];
@ -7572,212 +7605,44 @@ class Interpretation extends Fields
// start adding the dynamic
foreach ($this->listBuilder[$viewName_list] as $item)
{
// set the ref
$ref = '&ref=' . $refview . '&refid=<?php echo $id; ?>';
// set some defaults
$customAdminViewButtons = '';
// get list item code
$itemCode = $this->getListItemCode($item, $viewName_list, $doNotEscape, '$displayData->escape');
// is this a linked item
if (($item['link'] || (ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user')) && (!isset($item['custom']) || !isset($item['custom']['view']) || $refview !== $item['custom']['view']))
{
// set some defaults
$checkoutTriger = false;
// get list item link
$itemLink = $this->getListItemLink($item, $checkoutTriger, $viewName_single, $viewName_list, $ref);
// get list item link autority
$itemLinkAutority = $this->getListItemLinkAutority($item, $viewName_single, $viewName_list, $coreLoad, $core, '$user');
// set item row
$itemRow = $this->getListItemLinkRow($itemCode, $itemLink, $itemLinkAutority, $viewName_list, $checkoutTriger, false);
}
else
{
// set item row
$itemRow = PHP_EOL . "\t\t\t<?php echo " . $itemCode . "; ?>";
}
// check if buttons was aready added
if ($firstTimeBeingAdded) // TODO we must improve this to allow morw items to be targeted instead of just the first item :)
{
// get custom admin view buttons
$customAdminViewButtons = $this->getCustomAdminViewButtons($item, $viewName_single, $viewName_list, $coreLoad, $ref);
// make sure the custom admin view buttons are only added once
$firstTimeBeingAdded = false;
}
// add row to body
$body .= PHP_EOL . "\t\t<td>";
$body .= $itemRow;
$body .= $customAdminViewButtons;
$body .= PHP_EOL . "\t\t</td>";
// increment counter
$counter++;
$checkoutTriger = false;
if (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && isset($item['custom']['table']) && ComponentbuilderHelper::checkString($item['custom']['table']))
{
$item['id'] = $item['code'];
if (!$item['multiple'])
{
$item['code'] = $item['code'] . '_' . $item['custom']['text'];
}
}
// check if translated vlaue is used
if (isset($this->selectionTranslationFixBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->selectionTranslationFixBuilder[$viewName_list]) && array_key_exists($item['code'], $this->selectionTranslationFixBuilder[$viewName_list]))
{
$itemCode = '<?php echo JText:' . ':_($item->' . $item['code'] . '); ?>';
}
elseif ($item['custom']['text'] === 'user')
{
$itemCode = '<?php echo JFactory::getUser((int)$item->' . $item['code'] . ')->name; ?>';
}
elseif ($doNotEscape)
{
if (in_array($item['code'], $this->doNotEscape[$viewName_list]))
{
$itemCode = '<?php echo $item->' . $item['code'] . '; ?>';
}
else
{
$itemCode = '<?php echo $displayData->escape($item->' . $item['code'] . '); ?>';
}
}
else
{
$itemCode = '<?php echo $displayData->escape($item->' . $item['code'] . '); ?>';
}
if ($item['link'])
{
// allways rest custom links
$customAdminView = '';
// if to be linked
if ($item['type'] === 'category' && !$item['title'])
{
$otherViews = $this->catCodeBuilder[$viewName_single]['views'];
// category and linked
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$user->authorise('core.edit', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $otherViews . ".category.' . (int)\$item->" . $item['code'] . ")): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->' . $item['code'] . '; ?>&extension=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '.' . $otherViews . '"><?php echo $displayData->escape($item->category_title); ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$displayData->escape(\$item->category_title); ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
elseif ($item['type'] === 'user' && !$item['title'])
{
// user and linked
$body .= PHP_EOL . "\t\t<?php \$" . $item['code'] . "User = JFactory::getUser(\$item->" . $item['code'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$user->authorise('core.edit', 'com_users')): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['code'] . ' ?>"><?php echo $' . $item['code'] . 'User->name; ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$" . $item['code'] . "User->name; ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
else
{
$add = true;
if (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] != 'user' && !$item['title'])
{
if ($refview === $item['custom']['view'])
{
// normal not linked
$body .= PHP_EOL . "\t\t<td>";
$body .= PHP_EOL . "\t\t\t" . $itemCode;
$body .= PHP_EOL . "\t\t</td>";
$add = false;
}
else
{
// link to that item instead
$link = 'index.php?option=' . $item['custom']['component'] . '&view=' . $item['custom']['views'] . '&task=' . $item['custom']['view'] . '.edit&id=<?php echo $item->' . $item['id'] . '; ?>&ref=' . $refview . '&refid=<?php echo $id; ?>';
$coreLoadLink = false;
if (isset($this->permissionCore[$item['custom']['view']]))
{
$coreLink = $this->permissionCore[$item['custom']['view']];
$coreLoadLink = true;
}
// check if the item has permissions.
if ($coreLoadLink && isset($this->permissionBuilder[$coreLink['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$coreLink['core.edit']]) && in_array($item['custom']['view'], $this->permissionBuilder[$coreLink['core.edit']]))
{
$accessCheck = "\$user->authorise('" . $coreLink['core.edit'] . "', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $item['custom']['view'] . ".' . (int)\$item->" . $item['id'] . ")";
}
else
{
$accessCheck = "\$user->authorise('core.edit', 'com_" . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . "." . $item['custom']['view'] . ".' . (int)\$item->" . $item['id'] . ")";
}
}
}
elseif (isset($item['custom']) && ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user' && !$item['title'])
{
// user and linked
$body .= PHP_EOL . "\t\t<?php \$_" . $item['id'] . " = JFactory::getUser(\$item->" . $item['id'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (\$user->authorise('core.edit', 'com_users')): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['id'] . ' ?>"><?php echo $_' . $item['id'] . '->name; ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$_" . $item['id'] . "->name; ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
$add = false;
}
else
{
$link = '<?php echo $edit; ?>&id=<?php echo $item->id; ?>&ref=' . $refview . '&refid=<?php echo $id; ?>';
// check if custom links should be added to this list views
if (isset($this->customAdminViewListLink[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customAdminViewListLink[$viewName_list]) && $firstTimeBeingAdded)
{
// make sure the custom links are only added once
$firstTimeBeingAdded = false;
// start building the links
$customAdminView = PHP_EOL . "\t\t\t" . '<div class="btn-group">';
foreach ($this->customAdminViewListLink[$viewName_list] as $customLinkView)
{
$customAdminView .= PHP_EOL . "\t\t\t<?php if (\$canDo->get('" . $customLinkView['link'] . ".access')): ?>";
$customAdminView .= PHP_EOL . "\t\t\t\t" . '<a class="hasTooltip btn btn-mini" href="index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $customLinkView['link'] . '&id=<?php echo $item->id; ?>&ref=' . $refview . '&refid=<?php echo $id; ?>" title="<?php echo JText:' . ':_(' . "'COM_" . $this->fileContentStatic[$this->hhh . 'COMPONENT' . $this->hhh] . '_' . $customLinkView['NAME'] . "'" . '); ?>" ><span class="icon-' . $customLinkView['icon'] . '"></span></a>';
$customAdminView .= PHP_EOL . "\t\t\t<?php else: ?>";
$customAdminView .= PHP_EOL . "\t\t\t\t" . '<a class="hasTooltip btn btn-mini disabled" href="#" title="<?php echo JText:' . ':_(' . "'COM_" . $this->fileContentStatic[$this->hhh . 'COMPONENT' . $this->hhh] . '_' . $customLinkView['NAME'] . "'" . '); ?>"><span class="icon-' . $customLinkView['icon'] . '"></span></a>';
$customAdminView .= PHP_EOL . "\t\t\t<?php endif; ?>";
}
$customAdminView .= PHP_EOL . "\t\t\t" . '</div>';
}
// check if the item has permissions.
if ($coreLoad && isset($core['core.edit']) && isset($this->permissionBuilder['global'][$core['core.edit']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder['global'][$core['core.edit']]) && in_array($viewName_single, $this->permissionBuilder['global'][$core['core.edit']]))
{
// set permissions.
$accessCheck = "\$canDo->get('" . $core['core.edit'] . "')";
}
else
{
// set permissions.
$accessCheck = "\$canDo->get('core.edit')";
}
// triger the checked out script to be added
$checkoutTriger = true;
}
if ($add)
{
// set as linked
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php if (" . $accessCheck . "): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="' . $link . '">' . $itemCode . '</a>';
if ($checkoutTriger)
{
$body .= PHP_EOL . "\t\t\t\t\t<?php if (\$item->checked_out): ?>";
$body .= PHP_EOL . "\t\t\t\t\t\t<?php echo JHtml::_('jgrid.checkedout', \$i, \$userChkOut->name, \$item->checked_out_time, '" . $viewName_list . ".', \$canCheckin); ?>";
$body .= PHP_EOL . "\t\t\t\t\t<?php endif; ?>";
}
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<div class="name">' . $itemCode . '</div>';
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= $customAdminView;
$body .= PHP_EOL . "\t\t</td>";
}
}
}
else
{
if ($item['type'] === 'category')
{
$body .= PHP_EOL . "\t\t<td>";
$body .= PHP_EOL . "\t\t\t<?php echo \$displayData->escape(\$item->category_title); ?>";
$body .= PHP_EOL . "\t\t</td>";
}
elseif (ComponentbuilderHelper::checkArray($item['custom']) && $item['custom']['extends'] === 'user')
{
// custom user and linked
$body .= PHP_EOL . "\t\t<?php \$_" . $item['code'] . " = JFactory::getUser(\$item->" . $item['id'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td>';
$body .= PHP_EOL . "\t\t\t<?php if (\$user->authorise('core.edit', 'com_users')): ?>";
$body .= PHP_EOL . "\t\t\t\t" . '<a href="index.php?option=com_users&task=user.edit&id=<?php echo (int) $item->' . $item['id'] . ' ?>"><?php echo $_' . $item['code'] . '->name; ?></a>';
$body .= PHP_EOL . "\t\t\t<?php else: ?>";
$body .= PHP_EOL . "\t\t\t\t<?php echo \$_" . $item['code'] . "->name; ?>";
$body .= PHP_EOL . "\t\t\t<?php endif; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
elseif ($item['type'] === 'user')
{
// user name only
$body .= PHP_EOL . "\t\t<?php \$" . $item['code'] . "User = JFactory::getUser(\$item->" . $item['code'] . "); ?>";
$body .= PHP_EOL . "\t\t" . '<td class="' . $this->setListFieldClass($item['code'], $viewName_list, 'nowrap') . '">';
$body .= PHP_EOL . "\t\t\t<?php echo \$" . $item['code'] . "User->name; ?>";
$body .= PHP_EOL . "\t\t</td>";
}
else
{
// normal not linked
$body .= PHP_EOL . "\t\t<td>";
$body .= PHP_EOL . "\t\t\t" . $itemCode;
$body .= PHP_EOL . "\t\t</td>";
}
}
}
$counter = $counter + 2;
$data_value = (3 == $this->footableVersion) ? 'data-sort-value' : 'data-value';
@ -9303,7 +9168,7 @@ class Interpretation extends Fields
}
// set target type
$targetTypeSufix = "";
if ($this->defaultField($target['type'], 'spacer'))
if (ComponentbuilderHelper::fieldCheck($target['type'], 'spacer'))
{
// target a class if this is a note or spacer
$targetType = ".";
@ -9369,7 +9234,7 @@ class Interpretation extends Fields
{
case 1: // Is
// only 4 list/radio/checkboxes
if (ComponentbuilderHelper::typeField($type, 'list') || ComponentbuilderHelper::typeField($type, 'dynamic') || !ComponentbuilderHelper::typeField($type))
if (ComponentbuilderHelper::fieldCheck($type, 'list') || ComponentbuilderHelper::fieldCheck($type, 'dynamic') || !ComponentbuilderHelper::fieldCheck($type))
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -9400,7 +9265,7 @@ class Interpretation extends Fields
break;
case 2: // Is Not
// only 4 list/radio/checkboxes
if (ComponentbuilderHelper::typeField($type, 'list') || ComponentbuilderHelper::typeField($type, 'dynamic') || !ComponentbuilderHelper::typeField($type))
if (ComponentbuilderHelper::fieldCheck($type, 'list') || ComponentbuilderHelper::fieldCheck($type, 'dynamic') || !ComponentbuilderHelper::fieldCheck($type))
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -9431,7 +9296,7 @@ class Interpretation extends Fields
break;
case 3: // Any Selection
// only 4 list/radio/checkboxes/dynamic_list
if (ComponentbuilderHelper::typeField($type, 'list') || ComponentbuilderHelper::typeField($type, 'dynamic') || !ComponentbuilderHelper::typeField($type))
if (ComponentbuilderHelper::fieldCheck($type, 'list') || ComponentbuilderHelper::fieldCheck($type, 'dynamic') || !ComponentbuilderHelper::fieldCheck($type))
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -9469,21 +9334,21 @@ class Interpretation extends Fields
break;
case 4: // Active (not empty)
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
$string .= 'isSet(' . $value . ')';
}
break;
case 5: // Unactive (empty)
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
$string .= '!isSet(' . $value . ')';
}
break;
case 6: // Key Word All (case-sensitive)
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options['keywords']))
{
@ -9507,7 +9372,7 @@ class Interpretation extends Fields
break;
case 7: // Key Word Any (case-sensitive)
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options['keywords']))
{
@ -9531,7 +9396,7 @@ class Interpretation extends Fields
break;
case 8: // Key Word All (case-insensitive)
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options['keywords']))
{
@ -9556,7 +9421,7 @@ class Interpretation extends Fields
break;
case 9: // Key Word Any (case-insensitive)
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options['keywords']))
{
@ -9581,7 +9446,7 @@ class Interpretation extends Fields
break;
case 10: // Min Length
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -9598,7 +9463,7 @@ class Interpretation extends Fields
break;
case 11: // Max Length
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -9615,7 +9480,7 @@ class Interpretation extends Fields
break;
case 12: // Exact Length
// only 4 text_field
if (ComponentbuilderHelper::typeField($type, 'text'))
if (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
if (ComponentbuilderHelper::checkArray($options))
{
@ -9643,7 +9508,7 @@ class Interpretation extends Fields
$buket = array();
if (ComponentbuilderHelper::checkString($options))
{
if (ComponentbuilderHelper::typeField($type, 'list') || ComponentbuilderHelper::typeField($type, 'dynamic') || !ComponentbuilderHelper::typeField($type))
if (ComponentbuilderHelper::fieldCheck($type, 'list') || ComponentbuilderHelper::fieldCheck($type, 'dynamic') || !ComponentbuilderHelper::fieldCheck($type))
{
$optionsArray = array_map('trim', (array) explode(PHP_EOL, $options));
if (!ComponentbuilderHelper::checkArray($optionsArray))
@ -9663,7 +9528,7 @@ class Interpretation extends Fields
}
}
}
elseif (ComponentbuilderHelper::typeField($type, 'text'))
elseif (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
// check to get the key words if set
$keywords = ComponentbuilderHelper::getBetween($options, 'keywords="', '"');
@ -9721,12 +9586,12 @@ class Interpretation extends Fields
// this is only since 3.3.4
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '_id").val();';
}
elseif ($type === 'list' || ComponentbuilderHelper::typeField($type, 'dynamic') || !ComponentbuilderHelper::typeField($type))
elseif ($type === 'list' || ComponentbuilderHelper::fieldCheck($type, 'dynamic') || !ComponentbuilderHelper::fieldCheck($type))
{
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '").val();';
$isArray = true;
}
elseif (ComponentbuilderHelper::typeField($type, 'text'))
elseif (ComponentbuilderHelper::fieldCheck($type, 'text'))
{
$select = 'var ' . $keyName . ' = jQuery("#jform_' . $name . '").val();';
}

View File

@ -1801,7 +1801,7 @@ abstract class ComponentbuilderHelper
return $sufix === "" || ($sufix == substr(strrchr($file, "."), -strlen($sufix)));
}
public static function imageInfo($path,$request = 'type')
public static function imageInfo($path, $request = 'type')
{
// set image
$image = JPATH_SITE.'/'.$path;
@ -1914,37 +1914,79 @@ abstract class ComponentbuilderHelper
return array_unique($bucket);
}
public static function typeField($type,$option = 'default')
/**
* Field Grouping https://docs.joomla.org/Form_field
**/
protected static $fieldGroups = array(
'default' => array(
'accesslevel', 'cachehandler', 'calendar', 'captcha', 'category', 'checkbox',
'checkboxes', 'color', 'combo', 'componentlayout', 'contentlanguage', 'editor',
'chromestyle', 'contenttype', 'databaseconnection', 'editors', 'email', 'file',
'filelist', 'folderlist', 'groupedlist', 'hidden', 'file', 'headertag', 'helpsite',
'imagelist', 'integer', 'language', 'list', 'media', 'menu', 'note', 'number', 'password',
'plugins', 'radio', 'repeatable', 'range', 'rules', 'subform', 'sessionhandler', 'spacer', 'sql', 'tag',
'tel', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', 'moduletag',
'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup'
),
'plain' => array(
'accesslevel', 'checkbox', 'cachehandler', 'calendar', 'category', 'chromestyle', 'color',
'contenttype', 'combo', 'componentlayout', 'databaseconnection', 'editor', 'editors',
'email', 'file', 'filelist', 'folderlist', 'headertag', 'helpsite',
'hidden', 'imagelist', 'integer', 'language', 'media', 'menu',
'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules',
'sessionhandler', 'tag', 'tel', 'text', 'textarea',
'timezone', 'url', 'user', 'usergroup'
),
'text' => array(
'calendar','color','editor','email','password','tel','text','textarea','url','number','range'
),
'list' => array(
'checkboxes','checkbox','list','radio'
),
'dynamic' => array(
'category','headertag','tag','rules','user','file','filelist','folderlist','imagelist','integer','timezone','media','meter'
),
'spacer' => array(
'note', 'spacer'
),
'option' => array(
'plugins', 'checkboxes', 'contentlanguage', 'list', 'radio', 'sql'
),
'special' => array(
'contentlanguage', 'groupedlist', 'moduleposition', 'plugin',
'repeatable', 'templatestyle', 'subform'
)
);
/**
* Field Checker
*
* @param string $type The field type
* @param boolean $option The field grouping
*
* @return boolean if the field was found
*/
public static function fieldCheck($type, $option = 'default')
{
// list of default fields
// https://docs.joomla.org/Form_field
$fields = array(
'default' => array(
'accesslevel','cachehandler','calendar','captcha','category','checkbox',
'checkboxes','color','combo','componentlayout','contentlanguage','editor',
'chromestyle','contenttype','databaseconnection','editors','email','file',
'filelist','folderlist','groupedlist','hidden','file','headertag','helpsite',
'imagelist','integer','language','list','media','menu','note','password',
'plugins','range','radio','repeatable','rules','subform','sessionhandler','spacer','sql','tag',
'tel','menuitem','modulelayout','meter','moduleorder','moduleposition','moduletag',
'templatestyle','text','textarea','timezone','url','user','usergroup'
),
'text' => array(
'calendar','color','editor','email','password','tel','text','textarea','url','number','range'
),
'list' => array(
'checkboxes','checkbox','list','radio'
),
'dynamic' => array(
'category','headertag','tag','rules','user','file','filelist','folderlist','imagelist','integer','timezone','media','meter'
)
);
if (in_array($type,$fields[$option]))
// now check
if (isset(self::$fieldGroups[$option]) && in_array($type, self::$fieldGroups[$option]))
{
return true;
}
return false;
return false;
}
/**
* get the spacer IDs
*
* @return array ids of the spacer field types
*/
public static function getSpacerIds()
{
// get the database object to use quote
$db = JFactory::getDbo();
return self::getVars('fieldtype', (array) array_map(function($name) use($db) { return $db->quote(ucfirst($name)); }, self::$fieldGroups['spacer']), 'name', 'id');
}
/**