Skip to content

Commit

Permalink
Merge branch 'staging' into fix-schema-updates-3.9.8-2019-06-15
Browse files Browse the repository at this point in the history
  • Loading branch information
richard67 authored Jun 23, 2019
2 parents 3eb5986 + e48e9f1 commit c21850b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 68 deletions.
29 changes: 0 additions & 29 deletions administrator/components/com_contact/models/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,35 +526,6 @@ public function featured($pks, $value = 0)
return true;
}

/**
* Method to change the title & alias.
*
* @param integer $category_id The id of the parent.
* @param string $alias The alias.
* @param string $name The title.
*
* @return array Contains the modified title and alias.
*
* @since 3.1
*/
protected function generateNewTitle($category_id, $alias, $name)
{
// Alter the title & alias
$table = $this->getTable();

while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
{
if ($name == $table->name)
{
$name = StringHelper::increment($name);
}

$alias = StringHelper::increment($alias, 'dash');
}

return array($name, $alias);
}

/**
* Is the user allowed to create an on the fly category?
*
Expand Down
2 changes: 2 additions & 0 deletions administrator/components/com_contact/tables/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function __construct(&$db)
{
parent::__construct('#__contact_details', 'id', $db);

$this->setColumnAlias('title', 'name');

JTableObserverTags::createObserver($this, array('typeAlias' => 'com_contact.contact'));
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_contact.contact'));
}
Expand Down
29 changes: 0 additions & 29 deletions administrator/components/com_newsfeeds/models/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,35 +450,6 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
parent::preprocessForm($form, $data, $group);
}

/**
* Method to change the title & alias.
*
* @param integer $category_id The id of the parent.
* @param string $alias The alias.
* @param string $name The title.
*
* @return array Contains the modified title and alias.
*
* @since 3.1
*/
protected function generateNewTitle($category_id, $alias, $name)
{
// Alter the title & alias
$table = $this->getTable();

while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
{
if ($name == $table->name)
{
$name = StringHelper::increment($name);
}

$alias = StringHelper::increment($alias, 'dash');
}

return array($name, $alias);
}

/**
* Is the user allowed to create an on the fly category?
*
Expand Down
2 changes: 2 additions & 0 deletions administrator/components/com_newsfeeds/tables/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function __construct(&$db)
{
parent::__construct('#__newsfeeds', 'id', $db);

$this->setColumnAlias('title', 'name');

JTableObserverTags::createObserver($this, array('typeAlias' => 'com_newsfeeds.newsfeed'));
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_newsfeeds.newsfeed'));
}
Expand Down
8 changes: 4 additions & 4 deletions libraries/joomla/database/driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2203,10 +2203,10 @@ public function truncateTable($table)
/**
* Updates a row in a table based on an object's properties.
*
* @param string $table The name of the database table to update.
* @param object &$object A reference to an object whose public properties match the table fields.
* @param array $key The name of the primary key.
* @param boolean $nulls True to update null fields or false to ignore them.
* @param string $table The name of the database table to update.
* @param object &$object A reference to an object whose public properties match the table fields.
* @param array|string $key The name of the primary key.
* @param boolean $nulls True to update null fields or false to ignore them.
*
* @return boolean True on success.
*
Expand Down
21 changes: 15 additions & 6 deletions libraries/src/MVC/Model/AdminModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,18 @@ public function delete(&$pks)
protected function generateNewTitle($category_id, $alias, $title)
{
// Alter the title & alias
$table = $this->getTable();
$table = $this->getTable();
$aliasField = $table->getColumnAlias('alias');
$catidField = $table->getColumnAlias('catid');
$titleField = $table->getColumnAlias('title');

while ($table->load(array('alias' => $alias, 'catid' => $category_id)))
while ($table->load(array($aliasField => $alias, $catidField => $category_id)))
{
$title = StringHelper::increment($title);
if ($title === $table->$titleField)
{
$title = StringHelper::increment($title);
}

$alias = StringHelper::increment($alias, 'dash');
}

Expand Down Expand Up @@ -1531,9 +1538,11 @@ protected function checkCategoryId($categoryId)
public function generateTitle($categoryId, $table)
{
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias, $table->title);
$table->title = $data['0'];
$table->alias = $data['1'];
$titleField = $table->getColumnAlias('title');
$aliasField = $table->getColumnAlias('alias');
$data = $this->generateNewTitle($categoryId, $table->$aliasField, $table->$titleField);
$table->$titleField = $data['0'];
$table->$aliasField = $data['1'];
}

/**
Expand Down

0 comments on commit c21850b

Please sign in to comment.