Allow setting URL slug through admin panel.
This commit is contained in:
parent
c6c249787f
commit
bcbb74a680
@ -33,10 +33,11 @@ class EditAsset extends HTMLController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Key info
|
// Key info
|
||||||
if (isset($_POST['title'], $_POST['date_captured'], $_POST['priority']))
|
if (isset($_POST['title'], $_POST['slug'], $_POST['date_captured'], $_POST['priority']))
|
||||||
{
|
{
|
||||||
$date_captured = !empty($_POST['date_captured']) ? new DateTime($_POST['date_captured']) : null;
|
$date_captured = !empty($_POST['date_captured']) ? new DateTime($_POST['date_captured']) : null;
|
||||||
$asset->setKeyData(htmlentities($_POST['title']), $date_captured, intval($_POST['priority']));
|
$slug = strtr($_POST['slug'], [' ' => '-', '--' => '-', '&' => 'and', '=>' => '', "'" => "", ":"=> "", '\\' => '-']);
|
||||||
|
$asset->setKeyData(htmlentities($_POST['title']), $slug, $date_captured, intval($_POST['priority']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle tags
|
// Handle tags
|
||||||
|
@ -314,6 +314,11 @@ class Asset
|
|||||||
return ASSETSDIR . '/' . $this->subdir . '/' . $this->filename;
|
return ASSETSDIR . '/' . $this->subdir . '/' . $this->filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSlug()
|
||||||
|
{
|
||||||
|
return $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
public function getSubdir()
|
public function getSubdir()
|
||||||
{
|
{
|
||||||
return $this->subdir;
|
return $this->subdir;
|
||||||
@ -535,11 +540,12 @@ class Asset
|
|||||||
FROM assets');
|
FROM assets');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setKeyData($title, DateTime $date_captured = null, $priority)
|
public function setKeyData($title, $slug, DateTime $date_captured = null, $priority)
|
||||||
{
|
{
|
||||||
$params = [
|
$params = [
|
||||||
'id_asset' => $this->id_asset,
|
'id_asset' => $this->id_asset,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
|
'slug' => $slug,
|
||||||
'priority' => $priority,
|
'priority' => $priority,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -548,7 +554,8 @@ class Asset
|
|||||||
|
|
||||||
return Registry::get('db')->query('
|
return Registry::get('db')->query('
|
||||||
UPDATE assets
|
UPDATE assets
|
||||||
SET title = {string:title},' . (isset($date_captured) ? '
|
SET title = {string:title},
|
||||||
|
slug = {string:slug},' . (isset($date_captured) ? '
|
||||||
date_captured = {datetime:date_captured},' : '') . '
|
date_captured = {datetime:date_captured},' : '') . '
|
||||||
priority = {int:priority}
|
priority = {int:priority}
|
||||||
WHERE id_asset = {int:id_asset}',
|
WHERE id_asset = {int:id_asset}',
|
||||||
|
@ -65,6 +65,9 @@ class EditAssetForm extends SubTemplate
|
|||||||
<dt>Title</dt>
|
<dt>Title</dt>
|
||||||
<dd><input type="text" name="title" maxlength="255" size="70" value="', $this->asset->getTitle(), '">
|
<dd><input type="text" name="title" maxlength="255" size="70" value="', $this->asset->getTitle(), '">
|
||||||
|
|
||||||
|
<dt>URL slug</dt>
|
||||||
|
<dd><input type="text" name="slug" maxlength="255" size="70" value="', $this->asset->getSlug(), '">
|
||||||
|
|
||||||
<dt>Date captured</dt>
|
<dt>Date captured</dt>
|
||||||
<dd><input type="text" name="date_captured" size="30" value="',
|
<dd><input type="text" name="date_captured" size="30" value="',
|
||||||
$date_captured ? $date_captured->format('Y-m-d H:i:s') : '', '" placeholder="Y-m-d H:i:s">
|
$date_captured ? $date_captured->format('Y-m-d H:i:s') : '', '" placeholder="Y-m-d H:i:s">
|
||||||
|
Loading…
Reference in New Issue
Block a user