Added snippet types and libraries to snippets
This commit is contained in:
@ -90,11 +90,14 @@ $edit = "index.php?option=com_componentbuilder&view=snippets&task=snippet.edit";
|
||||
<?php echo $this->escape($item->url); ?>
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<?php echo JText::_($item->type); ?>
|
||||
<?php echo $this->escape($item->type_name); ?>
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<?php echo $this->escape($item->heading); ?>
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<?php echo $this->escape($item->library_name); ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($canDo->get('core.edit.state')) : ?>
|
||||
<?php if ($item->checked_out) : ?>
|
||||
|
@ -28,5 +28,5 @@ defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="8"><?php echo $this->pagination->getListFooter(); ?></td>
|
||||
<td colspan="9"><?php echo $this->pagination->getListFooter(); ?></td>
|
||||
</tr>
|
@ -50,11 +50,14 @@ defined('_JEXEC') or die('Restricted access');
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SNIPPET_URL_LABEL', 'url', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL', 'type', $this->listDirn, $this->listOrder); ?>
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL', 'type_name', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SNIPPET_HEADING_LABEL', 'heading', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<th class="nowrap hidden-phone" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL', 'library_name', $this->listDirn, $this->listOrder); ?>
|
||||
</th>
|
||||
<?php if ($this->canState): ?>
|
||||
<th width="10" class="nowrap center" >
|
||||
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_SNIPPET_STATUS', 'published', $this->listDirn, $this->listOrder); ?>
|
||||
|
@ -201,24 +201,46 @@ class ComponentbuilderViewSnippets extends JViewLegacy
|
||||
);
|
||||
}
|
||||
|
||||
// Set Type Selection
|
||||
$this->typeOptions = $this->getTheTypeSelections();
|
||||
if ($this->typeOptions)
|
||||
// Set Type Name Selection
|
||||
$this->typeNameOptions = JFormHelper::loadFieldType('Snippettype')->getOptions();
|
||||
if ($this->typeNameOptions)
|
||||
{
|
||||
// Type Filter
|
||||
// Type Name Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select '.JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL').' -',
|
||||
'filter_type',
|
||||
JHtml::_('select.options', $this->typeOptions, 'value', 'text', $this->state->get('filter.type'))
|
||||
JHtml::_('select.options', $this->typeNameOptions, 'value', 'text', $this->state->get('filter.type'))
|
||||
);
|
||||
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Type Batch Selection
|
||||
// Type Name Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL').' -',
|
||||
'batch[type]',
|
||||
JHtml::_('select.options', $this->typeOptions, 'value', 'text')
|
||||
JHtml::_('select.options', $this->typeNameOptions, 'value', 'text')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Set Library Name Selection
|
||||
$this->libraryNameOptions = JFormHelper::loadFieldType('Library')->getOptions();
|
||||
if ($this->libraryNameOptions)
|
||||
{
|
||||
// Library Name Filter
|
||||
JHtmlSidebar::addFilter(
|
||||
'- Select '.JText::_('COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL').' -',
|
||||
'filter_library',
|
||||
JHtml::_('select.options', $this->libraryNameOptions, 'value', 'text', $this->state->get('filter.library'))
|
||||
);
|
||||
|
||||
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||
{
|
||||
// Library Name Batch Selection
|
||||
JHtmlBatch_::addListSelection(
|
||||
'- Keep Original '.JText::_('COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL').' -',
|
||||
'batch[library]',
|
||||
JHtml::_('select.options', $this->libraryNameOptions, 'value', 'text')
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -266,45 +288,10 @@ class ComponentbuilderViewSnippets extends JViewLegacy
|
||||
'a.published' => JText::_('JSTATUS'),
|
||||
'a.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_NAME_LABEL'),
|
||||
'a.url' => JText::_('COM_COMPONENTBUILDER_SNIPPET_URL_LABEL'),
|
||||
'a.type' => JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL'),
|
||||
'g.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_TYPE_LABEL'),
|
||||
'a.heading' => JText::_('COM_COMPONENTBUILDER_SNIPPET_HEADING_LABEL'),
|
||||
'h.name' => JText::_('COM_COMPONENTBUILDER_SNIPPET_LIBRARY_LABEL'),
|
||||
'a.id' => JText::_('JGRID_HEADING_ID')
|
||||
);
|
||||
}
|
||||
|
||||
protected function getTheTypeSelections()
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select the text.
|
||||
$query->select($db->quoteName('type'));
|
||||
$query->from($db->quoteName('#__componentbuilder_snippet'));
|
||||
$query->order($db->quoteName('type') . ' ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
|
||||
$results = $db->loadColumn();
|
||||
|
||||
if ($results)
|
||||
{
|
||||
// get model
|
||||
$model = $this->getModel();
|
||||
$results = array_unique($results);
|
||||
$_filter = array();
|
||||
foreach ($results as $type)
|
||||
{
|
||||
// Translate the type selection
|
||||
$text = $model->selectionTranslation($type,'type');
|
||||
// Now add the type and its text to the options array
|
||||
$_filter[] = JHtml::_('select.option', $type, JText::_($text));
|
||||
}
|
||||
return $_filter;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user