Fixed gh-272 by updating the table method generateAlias to also make use of the custom alias builder values.

This commit is contained in:
Llewellyn van der Merwe 2018-05-03 01:12:06 +02:00
parent 2f4f9ff0a3
commit e905aa895f
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
36 changed files with 764 additions and 739 deletions

View File

@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
+ *Version*: 2.7.7 + *Version*: 2.7.7
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **193966** + *Line count*: **193953**
+ *Field count*: **1027** + *Field count*: **1027**
+ *File count*: **1201** + *File count*: **1201**
+ *Folder count*: **193** + *Folder count*: **193**

View File

@ -130,7 +130,7 @@ Component Builder is mapped as a component in itself on my local development env
+ *Version*: 2.7.7 + *Version*: 2.7.7
+ *Copyright*: Copyright (C) 2015. All Rights Reserved + *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **193966** + *Line count*: **193953**
+ *Field count*: **1027** + *Field count*: **1027**
+ *File count*: **1201** + *File count*: **1201**
+ *Folder count*: **193** + *Folder count*: **193**

View File

@ -323,29 +323,6 @@ class ###Component###Table###View### extends JTable
$asset->loadByName('com_###component###'); $asset->loadByName('com_###component###');
return $asset->id; return $asset->id;
} }###GENERATENEWALIAS###
/**
* Generate a valid alias from title / date.
* Remains public to be able to check for duplicated alias before saving
*
* @return string
*/
public function generateAlias()
{
if (empty($this->alias))
{
$this->alias = $this->name;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
return $this->alias;
}
} }

View File

@ -5754,6 +5754,64 @@ class Interpretation extends Fields
return ''; return '';
} }
public function setGenerateNewAlias($viewName_single)
{
// make sure this view has an alias
if (isset($this->customAliasBuilder[$viewName_single]) || isset($this->titleBuilder[$viewName_single]))
{
// set the title stuff
if (isset($this->customAliasBuilder[$viewName_single]))
{
$titles = array_values($this->customAliasBuilder[$viewName_single]);
}
else
{
$titles = array($this->titleBuilder[$viewName_single]);
}
// reset the bucket
$titleData = array();
// load the dynamic title builder
foreach ($titles as $title)
{
$titleData[] = "\$this->" . $title;
}
// rest the new function
$newFunction = array();
$newFunction[] = PHP_EOL . PHP_EOL . "\t/**";
$newFunction[] = "\t* Generate a valid alias from title / date.";
$newFunction[] = "\t* Remains public to be able to check for duplicated alias before saving";
$newFunction[] = "\t*";
$newFunction[] = "\t* @return string";
$newFunction[] = "\t*/";
$newFunction[] = "\tpublic function generateAlias()";
$newFunction[] = "\t{";
$newFunction[] = "\t\tif (empty(\$this->alias))";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$this->alias = ".implode(".' '.",$titleData).';';
$newFunction[] = "\t\t}";
$newFunction[] = PHP_EOL ."\t\t\$this->alias = JApplication::stringURLSafe(\$this->alias);";
$newFunction[] = PHP_EOL ."\t\tif (trim(str_replace('-', '', \$this->alias)) == '')";
$newFunction[] = "\t\t{";
$newFunction[] = "\t\t\t\$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');";
$newFunction[] = "\t\t}";
$newFunction[] = PHP_EOL ."\t\treturn \$this->alias;";
$newFunction[] = "\t}";
return implode(PHP_EOL, $newFunction);
}
// rest the new function
$newFunction = array();
$newFunction[] = PHP_EOL . PHP_EOL . "\t/**";
$newFunction[] = "\t* This view does not actually have an alias";
$newFunction[] = "\t*";
$newFunction[] = "\t* @return bool";
$newFunction[] = "\t*/";
$newFunction[] = "\tpublic function generateAlias()";
$newFunction[] = "\t{";
$newFunction[] = "\t\treturn false;";
$newFunction[] = "\t}";
return implode(PHP_EOL, $newFunction);
}
public function setInstall() public function setInstall()
{ {
if (isset($this->queryBuilder) && ComponentbuilderHelper::checkArray($this->queryBuilder)) if (isset($this->queryBuilder) && ComponentbuilderHelper::checkArray($this->queryBuilder))

View File

@ -514,6 +514,9 @@ class Infusion extends Interpretation
// ###GENERATENEWTITLE### <<<DYNAMIC>>> // ###GENERATENEWTITLE### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###GENERATENEWTITLE###'] = $this->setGenerateNewTitle($viewName_single); $this->fileContentDynamic[$viewName_single]['###GENERATENEWTITLE###'] = $this->setGenerateNewTitle($viewName_single);
// ###GENERATENEWALIAS### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###GENERATENEWALIAS###'] = $this->setGenerateNewAlias($viewName_single);
// ###MODEL_BATCH_COPY### <<<DYNAMIC>>> // ###MODEL_BATCH_COPY### <<<DYNAMIC>>>
$this->fileContentDynamic[$viewName_single]['###MODEL_BATCH_COPY###'] = $this->setBatchCopy($viewName_single); $this->fileContentDynamic[$viewName_single]['###MODEL_BATCH_COPY###'] = $this->setBatchCopy($viewName_single);

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableAdmin_fields extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->admin_view;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableAdmin_fields_conditions extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->admin_view;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -326,26 +326,13 @@ class ComponentbuilderTableAdmin_view extends JTable
} }
/** /**
* Generate a valid alias from title / date. * This view does not actually have an alias
* Remains public to be able to check for duplicated alias before saving
* *
* @return string * @return bool
*/ */
public function generateAlias() public function generateAlias()
{ {
if (empty($this->alias)) return false;
{
$this->alias = $this->name;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
return $this->alias;
} }
} }

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_admin_views extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_config extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_custom_admin_menus extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_custom_admin_views extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_dashboard extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_files_folders extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_mysql_tweaks extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_site_views extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableComponent_updates extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->joomla_component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableCustom_admin_view extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableCustom_code extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->component;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableDynamic_get extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableField extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableFieldtype extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableHelp_document extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->title;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableJoomla_component extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->system_name;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableLanguage extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableLanguage_translation extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->source;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableLayout extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableLibrary extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableLibrary_config extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->library;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -335,14 +335,14 @@ class ComponentbuilderTableLibrary_files_folders_urls extends JTable
{ {
if (empty($this->alias)) if (empty($this->alias))
{ {
$this->alias = $this->name; $this->alias = $this->library;
} }
$this->alias = JApplication::stringURLSafe($this->alias); $this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableServer extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableSite_view extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableSnippet extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableSnippet_type extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableTemplate extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;

View File

@ -342,7 +342,7 @@ class ComponentbuilderTableValidation_rule extends JTable
if (trim(str_replace('-', '', $this->alias)) == '') if (trim(str_replace('-', '', $this->alias)) == '')
{ {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); $this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
} }
return $this->alias; return $this->alias;