Merge e36ce4328c68d7a617f4ea4e2f7073ca385686d9 into 070a0c40fe84d932a5406e86e590690ecc56e2be
This commit is contained in:
commit
15cfdf2e62
@ -103,13 +103,16 @@ class dbList extends dbJSON
|
|||||||
return $this->save();
|
return $this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit($oldKey, $newName)
|
public function edit($oldKey, $newName, $properties)
|
||||||
{
|
{
|
||||||
$newKey = $this->generateKey($newName);
|
$newKey = $this->generateKey($newName);
|
||||||
|
|
||||||
$this->db[$newKey]['name'] = Sanitize::html($newName);
|
$this->db[$newKey]['name'] = Sanitize::html($newName);
|
||||||
$this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
|
$this->db[$newKey]['list'] = $this->db[$oldKey]['list'];
|
||||||
|
|
||||||
|
foreach ($properties as $propertyKey => $propertyValue)
|
||||||
|
$this->db[$newKey][$propertyKey] = Sanitize::html($propertyValue);
|
||||||
|
|
||||||
// Remove the old key
|
// Remove the old key
|
||||||
if( $oldKey != $newKey ) {
|
if( $oldKey != $newKey ) {
|
||||||
unset( $this->db[$oldKey] );
|
unset( $this->db[$oldKey] );
|
||||||
@ -130,8 +133,14 @@ class dbList extends dbJSON
|
|||||||
// Returns the name associated to the key, FALSE if the key doesn't exist
|
// Returns the name associated to the key, FALSE if the key doesn't exist
|
||||||
public function getName($key)
|
public function getName($key)
|
||||||
{
|
{
|
||||||
if( isset($this->db[$key]) ) {
|
return $this->getProperty($key, 'name');
|
||||||
return $this->db[$key]['name'];
|
}
|
||||||
|
|
||||||
|
// Returns a property associated to the key, FALSE if the key doesn't exist
|
||||||
|
public function getProperty($key, $property)
|
||||||
|
{
|
||||||
|
if( isset($this->db[$key]) && isset($this->db[$key][$property])) {
|
||||||
|
return $this->db[$key][$property];
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,7 +26,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||||||
deleteCategory($_POST['categoryKey']);
|
deleteCategory($_POST['categoryKey']);
|
||||||
}
|
}
|
||||||
elseif (isset($_POST['edit'])) {
|
elseif (isset($_POST['edit'])) {
|
||||||
editCategory($_POST['categoryKey'], $_POST['category']);
|
editCategory($_POST['categoryKey'], $_POST['category'], $_POST['categoryDescription']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Redirect::page('categories');
|
Redirect::page('categories');
|
||||||
|
@ -21,6 +21,13 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
|||||||
'class'=>'uk-width-1-2 uk-form-medium'
|
'class'=>'uk-width-1-2 uk-form-medium'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
HTML::formTextArea(array(
|
||||||
|
'name'=>'categoryDescription',
|
||||||
|
'label'=>$L->g('Description'),
|
||||||
|
'value'=>$dbCategories->getProperty($categoryKey, 'description'),
|
||||||
|
'class'=>'uk-width-1-2 uk-form-medium'
|
||||||
|
));
|
||||||
|
|
||||||
echo '<div class="uk-form-row">
|
echo '<div class="uk-form-row">
|
||||||
<div class="uk-form-controls">
|
<div class="uk-form-controls">
|
||||||
<button type="submit" name="edit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
<button type="submit" name="edit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||||
|
@ -733,7 +733,7 @@ function createCategory($category) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editCategory($oldCategoryKey, $newCategory) {
|
function editCategory($oldCategoryKey, $newCategory, $newDescription) {
|
||||||
global $Language;
|
global $Language;
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
global $dbCategories;
|
global $dbCategories;
|
||||||
@ -744,7 +744,8 @@ function editCategory($oldCategoryKey, $newCategory) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $dbCategories->edit($oldCategoryKey, $newCategory) == false ) {
|
$properties = array('description' => $newDescription);
|
||||||
|
if( $dbCategories->edit($oldCategoryKey, $newCategory, $properties) == false ) {
|
||||||
Alert::set($Language->g('Already exist a category'));
|
Alert::set($Language->g('Already exist a category'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -222,6 +222,13 @@ class Page {
|
|||||||
return $this->getValue('category');
|
return $this->getValue('category');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the category description
|
||||||
|
public function categoryDescription()
|
||||||
|
{
|
||||||
|
global $dbCategories;
|
||||||
|
return $dbCategories->getProperty($this->categoryKey(), 'description');
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the field from the array
|
// Returns the field from the array
|
||||||
// categoryMap = array( 'name'=>'', 'list'=>array() )
|
// categoryMap = array( 'name'=>'', 'list'=>array() )
|
||||||
public function categoryMap($field)
|
public function categoryMap($field)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user