Added the option for automatic alias building, resolve gh-246. Made improvements to the buttons all over JCB, and the tweaked the field view a little more.

This commit is contained in:
2018-03-28 11:46:14 +02:00
parent 0ba2a0e8cf
commit 4e740f568e
57 changed files with 1217 additions and 590 deletions

View File

@ -885,7 +885,7 @@ class ComponentbuilderModelLayout extends JModelAdmin
// Automatic handling of alias for empty fields
if (in_array($input->get('task'), array('apply', 'save', 'save2new')) && (int) $input->get('id') == 0)
{
if ($data['alias'] == null)
if ($data['alias'] == null || empty($data['alias']))
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
@ -903,8 +903,7 @@ class ComponentbuilderModelLayout extends JModelAdmin
$msg = JText::_('COM_COMPONENTBUILDER_LAYOUT_SAVE_WARNING');
}
list($name, $alias) = $this->_generateNewTitle($data['alias'], $data['name']);
$data['alias'] = $alias;
$data['alias'] = $this->_generateNewTitle($data['alias']);
if (isset($msg))
{
@ -959,26 +958,49 @@ class ComponentbuilderModelLayout extends JModelAdmin
}
/**
* Method to change the title & alias.
* Method to change the title/s & alias.
*
* @param string $alias The alias.
* @param string $title The title.
* @param string $alias The alias.
* @param string/array $title The title.
*
* @return array Contains the modified title and alias.
* @return array/string Contains the modified title/s and/or alias.
*
*/
protected function _generateNewTitle($alias, $title)
protected function _generateNewTitle($alias, $title = null)
{
// Alter the title & alias
// Alter the title/s & alias
$table = $this->getTable();
while ($table->load(array('alias' => $alias)))
{
$title = JString::increment($title);
// Check if this is an array of titles
if (ComponentbuilderHelper::checkArray($title))
{
foreach($title as $nr => &$_title)
{
$_title = JString::increment($_title);
}
}
// Make sure we have a title
elseif ($title)
{
$title = JString::increment($title);
}
$alias = JString::increment($alias, 'dash');
}
return array($title, $alias);
// Check if this is an array of titles
if (ComponentbuilderHelper::checkArray($title))
{
$title[] = $alias;
return $title;
}
// Make sure we have a title
elseif ($title)
{
return array($title, $alias);
}
// We only had an alias
return $alias;
}
}