improved the table method generateAlias to only get added if there is an alias in the view

This commit is contained in:
Llewellyn van der Merwe 2018-05-03 01:26:41 +02:00
parent e905aa895f
commit f200e635b8
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
30 changed files with 94 additions and 438 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*: **193953** + *Line count*: **193602**
+ *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*: **193953** + *Line count*: **193602**
+ *Field count*: **1027** + *Field count*: **1027**
+ *File count*: **1201** + *File count*: **1201**
+ *Folder count*: **193** + *Folder count*: **193**

View File

@ -5757,24 +5757,31 @@ class Interpretation extends Fields
public function setGenerateNewAlias($viewName_single) public function setGenerateNewAlias($viewName_single)
{ {
// make sure this view has an alias // make sure this view has an alias
if (isset($this->customAliasBuilder[$viewName_single]) || isset($this->titleBuilder[$viewName_single])) if (isset($this->aliasBuilder[$viewName_single]))
{ {
// set the title stuff // set the title stuff
if (isset($this->customAliasBuilder[$viewName_single])) if (isset($this->customAliasBuilder[$viewName_single]))
{ {
$titles = array_values($this->customAliasBuilder[$viewName_single]); $titles = array_values($this->customAliasBuilder[$viewName_single]);
} }
else elseif (isset($this->titleBuilder[$viewName_single]))
{ {
$titles = array($this->titleBuilder[$viewName_single]); $titles = array($this->titleBuilder[$viewName_single]);
} }
// reset the bucket // reset the bucket
$titleData = array(); $titleData = array();
// load the dynamic title builder // load the dynamic title builder
if (isset($titles) && ComponentbuilderHelper::checkArray($titles))
{
foreach ($titles as $title) foreach ($titles as $title)
{ {
$titleData[] = "\$this->" . $title; $titleData[] = "\$this->" . $title;
} }
}
else
{
$titleData = array("''"); // just incase some mad man does not set a title/customAlias (we fall back on the date)
}
// rest the new function // rest the new function
$newFunction = array(); $newFunction = array();
$newFunction[] = PHP_EOL . PHP_EOL . "\t/**"; $newFunction[] = PHP_EOL . PHP_EOL . "\t/**";

View File

@ -326,26 +326,13 @@ class ComponentbuilderTableAdmin_fields 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->admin_view;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableAdmin_fields_conditions 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->admin_view;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_admin_views 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_config 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_custom_admin_menus 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_custom_admin_views 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_dashboard 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_files_folders 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_mysql_tweaks 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_site_views 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableComponent_updates 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->joomla_component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableCustom_admin_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

@ -326,26 +326,13 @@ class ComponentbuilderTableCustom_code 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->component;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableDynamic_get 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

@ -326,26 +326,13 @@ class ComponentbuilderTableField 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

@ -326,26 +326,13 @@ class ComponentbuilderTableFieldtype 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

@ -326,26 +326,13 @@ class ComponentbuilderTableJoomla_component 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->system_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

@ -326,26 +326,13 @@ class ComponentbuilderTableLanguage 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

@ -326,26 +326,13 @@ class ComponentbuilderTableLanguage_translation 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->source;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableLibrary 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

@ -326,26 +326,13 @@ class ComponentbuilderTableLibrary_config 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->library;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableLibrary_files_folders_urls 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->library;
}
$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

@ -326,26 +326,13 @@ class ComponentbuilderTableServer 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

@ -326,26 +326,13 @@ class ComponentbuilderTableSite_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

@ -326,26 +326,13 @@ class ComponentbuilderTableSnippet 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

@ -326,26 +326,13 @@ class ComponentbuilderTableSnippet_type 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

@ -326,26 +326,13 @@ class ComponentbuilderTableValidation_rule 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;
} }
} }