Ver código fonte

Fix default category name (#6073)

fix https://github.com/FreshRSS/FreshRSS/issues/6071
Alexandre Alapetite 2 anos atrás
pai
commit
6228f959f7
2 arquivos alterados com 6 adições e 4 exclusões
  1. 4 2
      app/Models/Category.php
  2. 2 2
      app/views/helpers/category/update.phtml

+ 4 - 2
app/Models/Category.php

@@ -124,7 +124,7 @@ class FreshRSS_Category extends Minz_Model {
 	public function _id(int $id): void {
 		$this->id = $id;
 		if ($id === FreshRSS_CategoryDAO::DEFAULTCATEGORYID) {
-			$this->_name(_t('gen.short.default_category'));
+			$this->name = _t('gen.short.default_category');
 		}
 	}
 
@@ -133,7 +133,9 @@ class FreshRSS_Category extends Minz_Model {
 	}
 
 	public function _name(string $value): void {
-		$this->name = mb_strcut(trim($value), 0, FreshRSS_DatabaseDAO::LENGTH_INDEX_UNICODE, 'UTF-8');
+		if ($this->id !== FreshRSS_CategoryDAO::DEFAULTCATEGORYID) {
+			$this->name = mb_strcut(trim($value), 0, FreshRSS_DatabaseDAO::LENGTH_INDEX_UNICODE, 'UTF-8');
+		}
 	}
 
 	/** @param array<FreshRSS_Feed>|FreshRSS_Feed $values */

+ 2 - 2
app/views/helpers/category/update.phtml

@@ -22,9 +22,9 @@
 		<div class="form-group">
 			<label class="group-name" for="name"><?= _t('sub.category.title') ?></label>
 			<div class="group-controls">
-				<input type="text" name="name" id="name" value="<?= $this->category->name()  ?>" <?php
+				<input type="text" name="name" id="name" value="<?= $this->category->name()  ?>" <?=
 					//Disallow changing the name of the default category
-					echo $this->category->id() == FreshRSS_CategoryDAO::DEFAULTCATEGORYID ? 'disabled="disabled"' : '';
+					$this->category->id() === FreshRSS_CategoryDAO::DEFAULTCATEGORYID ? 'readonly="readonly"' : ''
 				?> />
 			</div>
 		</div>