Version 5.0.0 release
This commit is contained in:
1 parent
90e8c7e903
commit
a3a4a9ccbd
651 files changed
+7275
-9481
No files matched your search
@@ -21,10 +21,8 @@ use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Icon;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\Translatable;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
@@ -74,11 +72,6 @@ class Category extends Model
|
||||
*/
|
||||
public static ?string $databaseColumnParent = 'parent';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$titleLangPrefix}_{$id}" as the key
|
||||
*/
|
||||
public static ?string $titleLangPrefix = 'themeeditor_cat_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Show forms modally?
|
||||
*/
|
||||
@@ -106,7 +99,7 @@ class Category extends Model
|
||||
*/
|
||||
protected function get__title(): string
|
||||
{
|
||||
return Member::loggedIn()->language()->addToStack( static::$titleLangPrefix . $this->key, NULL, array( 'escape' => TRUE ) );
|
||||
return $this->name ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +112,7 @@ class Category extends Model
|
||||
*/
|
||||
public function getTitleForLanguage( Lang $language, array $options=array() ): string
|
||||
{
|
||||
return $language->addToStack( static::$titleLangPrefix . $this->key, NULL, $options );
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +122,7 @@ class Category extends Model
|
||||
*/
|
||||
protected function get__titleLanguageKey(): ?string
|
||||
{
|
||||
return static::$titleLangPrefix . $this->key;
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,10 +309,7 @@ class Category extends Model
|
||||
*/
|
||||
public function form( Form &$form ) : void
|
||||
{
|
||||
$form->add( new Translatable( 'themeeditor_cat_name', null, true, array(
|
||||
'app' => 'core',
|
||||
'key' => ( $this->id ? 'themeeditor_cat_' . $this->key : null )
|
||||
) ) );
|
||||
$form->add( new Text( 'themeeditor_cat_name', $this->name, true ) );
|
||||
|
||||
$form->add( new Text( 'themeeditor_cat_key', $this->key, true, array(
|
||||
'regex' => '/[A-Z]+/i',
|
||||
@@ -375,12 +365,6 @@ class Category extends Model
|
||||
*/
|
||||
public function formatFormValues( array $values ): array
|
||||
{
|
||||
if( !$this->id )
|
||||
{
|
||||
$this->key = $values['themeeditor_cat_key'];
|
||||
$this->save();
|
||||
}
|
||||
|
||||
$icon = $values['themeeditor_cat_icon'][0];
|
||||
if( $values['themeeditor_cat_icon_extra'] )
|
||||
{
|
||||
@@ -388,6 +372,7 @@ class Category extends Model
|
||||
}
|
||||
|
||||
$return = [
|
||||
'cat_name' => $values['themeeditor_cat_name'],
|
||||
'cat_key' => $values['themeeditor_cat_key'],
|
||||
'cat_icon' => json_encode( $icon ),
|
||||
'cat_parent' => ( $values['themeeditor_cat_parent'] instanceof Model ? $values['themeeditor_cat_parent']->id : 0 ),
|
||||
@@ -399,8 +384,6 @@ class Category extends Model
|
||||
$return['cat_app'] = $values['themeeditor_cat_app']->directory;
|
||||
}
|
||||
|
||||
Lang::saveCustom( 'core', static::$titleLangPrefix . $values['themeeditor_cat_key'], $values['themeeditor_cat_name'] );
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -527,15 +510,4 @@ class Category extends Model
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete(): void
|
||||
{
|
||||
parent::delete();
|
||||
Lang::deleteCustom( 'core', static::$titleLangPrefix . $this->key );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user