Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,116 +12,125 @@
|
||||
namespace IPS\cms\Selector;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\cms\Databases;
|
||||
use IPS\cms\Pages\Page;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Node\Permissions;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Categories Model
|
||||
*/
|
||||
class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
class Categories extends Model implements Permissions
|
||||
{
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons = array();
|
||||
protected static array $multitons = array();
|
||||
|
||||
/**
|
||||
* @brief [Records] Custom Database Id
|
||||
*/
|
||||
public static $customDatabaseId = NULL;
|
||||
public static ?int $customDatabaseId = NULL;
|
||||
|
||||
/**
|
||||
* @brief [Records] Content item class
|
||||
*/
|
||||
public static $contentItemClass = NULL;
|
||||
public static ?string $contentItemClass = NULL;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'cms_database_categories';
|
||||
public static ?string $databaseTable = 'cms_database_categories';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'category_';
|
||||
public static string $databasePrefix = 'category_';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Column
|
||||
*/
|
||||
public static $databaseColumnId = 'id';
|
||||
public static string $databaseColumnId = 'id';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database ID Fields
|
||||
*/
|
||||
protected static $databaseIdFields = array('category_furl_name', 'category_full_path');
|
||||
protected static array $databaseIdFields = array('category_furl_name', 'category_full_path');
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Map
|
||||
*/
|
||||
protected static $multitonMap = array();
|
||||
protected static array $multitonMap = array();
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
public static $databaseColumnParent = 'parent_id';
|
||||
public static ?string $databaseColumnParent = 'parent_id';
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'position';
|
||||
public static ?string $databaseColumnOrder = 'position';
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent Node ID Database Column
|
||||
*/
|
||||
public static $parentNodeColumnId = 'database_id';
|
||||
public static string $parentNodeColumnId = 'database_id';
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent Node Class
|
||||
*/
|
||||
public static $parentNodeClass = 'IPS\cms\Selector\Databases';
|
||||
public static string $parentNodeClass = 'IPS\cms\Selector\Databases';
|
||||
|
||||
/**
|
||||
* @brief [Node] Show forms modally?
|
||||
*/
|
||||
public static $modalForms = FALSE;
|
||||
public static bool $modalForms = FALSE;
|
||||
|
||||
/**
|
||||
* @brief [Node] Sortable?
|
||||
*/
|
||||
public static $nodeSortable = TRUE;
|
||||
public static bool $nodeSortable = TRUE;
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'r__categories';
|
||||
public static string $nodeTitle = 'r__categories';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'content_cat_name_';
|
||||
public static ?string $titleLangPrefix = 'content_cat_name_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Description suffix. If specified, will look for a language key with "{$titleLangPrefix}_{$id}_{$descriptionLangSuffix}" as the key
|
||||
*/
|
||||
public static $descriptionLangSuffix = '_desc';
|
||||
public static ?string $descriptionLangSuffix = '_desc';
|
||||
|
||||
/**
|
||||
* @brief [Node] App for permission index
|
||||
*/
|
||||
public static $permApp = 'cms';
|
||||
public static ?string $permApp = 'cms';
|
||||
|
||||
/**
|
||||
* @brief [Node] Type for permission index
|
||||
*/
|
||||
public static $permType = 'categories';
|
||||
public static ?string $permType = 'categories';
|
||||
|
||||
/**
|
||||
* @brief The map of permission columns
|
||||
*/
|
||||
public static $permissionMap = array(
|
||||
public static array $permissionMap = array(
|
||||
'view' => 'view',
|
||||
'read' => 2,
|
||||
'add' => 3,
|
||||
@@ -134,31 +143,31 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
/**
|
||||
* @brief [Node] Moderator Permission
|
||||
*/
|
||||
public static $modPerm = 'cms';
|
||||
public static string $modPerm = 'cms';
|
||||
|
||||
/**
|
||||
* @brief [Node] Prefix string that is automatically prepended to permission matrix language strings
|
||||
*/
|
||||
public static $permissionLangPrefix = 'perm_content_';
|
||||
public static string $permissionLangPrefix = 'perm_content_';
|
||||
|
||||
/**
|
||||
* Get title of category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get__title()
|
||||
protected function get__title(): string
|
||||
{
|
||||
/* If the DB is in a page, and we're not using categories, then return the page title, not the category title for continuity */
|
||||
if ( ! \IPS\cms\Databases::load( $this->database_id )->use_categories )
|
||||
if ( ! Databases::load( $this->database_id )->use_categories )
|
||||
{
|
||||
if ( ! $this->_catTitle )
|
||||
{
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::loadByDatabaseId( $this->database_id );
|
||||
$page = Page::loadByDatabaseId( $this->database_id );
|
||||
$this->_catTitle = $page->_title;
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
$this->_catTitle = parent::get__title();
|
||||
}
|
||||
@@ -172,19 +181,39 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief [Records] Database objects
|
||||
*/
|
||||
protected static array $database = array();
|
||||
|
||||
/**
|
||||
* Returns the database parent
|
||||
*
|
||||
* @return Databases
|
||||
*/
|
||||
public static function database(): Databases
|
||||
{
|
||||
if ( !isset( static::$database[ static::$customDatabaseId ] ) )
|
||||
{
|
||||
static::$database[ static::$customDatabaseId ] = Databases::load( static::$customDatabaseId );
|
||||
}
|
||||
|
||||
return static::$database[ static::$customDatabaseId ];
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get Description
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function get__description()
|
||||
protected function get__description(): ?string
|
||||
{
|
||||
if ( ! static::database()->use_categories )
|
||||
{
|
||||
return static::database()->_description;
|
||||
}
|
||||
|
||||
return ( \IPS\Member::loggedIn()->language()->addToStack('content_cat_name_' . $this->id . '_desc') === 'content_cat_name_' . $this->id . '_desc' ) ? $this->description : \IPS\Member::loggedIn()->language()->addToStack('content_cat_name_' . $this->id . '_desc');
|
||||
return ( Member::loggedIn()->language()->addToStack('content_cat_name_' . $this->id . '_desc') === 'content_cat_name_' . $this->id . '_desc' ) ? $this->description : Member::loggedIn()->language()->addToStack('content_cat_name_' . $this->id . '_desc');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,71 +12,76 @@
|
||||
namespace IPS\cms\Selector;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Node\Model;
|
||||
use IPS\Node\Permissions;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Databases Model
|
||||
*/
|
||||
class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
class Databases extends Model implements Permissions
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons = array();
|
||||
protected static array $multitons = array();
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'database_';
|
||||
public static string $databasePrefix = 'database_';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Table
|
||||
*/
|
||||
public static $databaseTable = 'cms_databases';
|
||||
public static ?string $databaseTable = 'cms_databases';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Column
|
||||
*/
|
||||
public static $databaseColumnId = 'id';
|
||||
public static string $databaseColumnId = 'id';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database ID Fields
|
||||
*/
|
||||
protected static $databaseIdFields = array( 'database_key', 'database_page_id' );
|
||||
protected static array $databaseIdFields = array( 'database_key', 'database_page_id' );
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Map
|
||||
*/
|
||||
protected static $multitonMap = array();
|
||||
protected static array $multitonMap = array();
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'id';
|
||||
public static ?string $databaseColumnOrder = 'id';
|
||||
|
||||
/**
|
||||
* @brief [Node] Sortable?
|
||||
*/
|
||||
public static $nodeSortable = FALSE;
|
||||
public static bool $nodeSortable = FALSE;
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = '';
|
||||
public static string $nodeTitle = '';
|
||||
|
||||
/**
|
||||
* @brief [Node] Subnode class
|
||||
*/
|
||||
public static $subnodeClass = 'IPS\cms\Selector\Categories';
|
||||
public static ?string $subnodeClass = 'IPS\cms\Selector\Categories';
|
||||
|
||||
/**
|
||||
* @brief The map of permission columns
|
||||
*/
|
||||
public static $permissionMap = array(
|
||||
public static array $permissionMap = array(
|
||||
'view' => 'view',
|
||||
'read' => 2,
|
||||
'add' => 3,
|
||||
@@ -89,25 +94,25 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
/**
|
||||
* @brief [Node] App for permission index
|
||||
*/
|
||||
public static $permApp = 'cms';
|
||||
public static ?string $permApp = 'cms';
|
||||
|
||||
/**
|
||||
* @brief [Node] Type for permission index
|
||||
*/
|
||||
public static $permType = 'databases';
|
||||
public static ?string $permType = 'databases';
|
||||
|
||||
/**
|
||||
* @brief [Node] Prefix string that is automatically prepended to permission matrix language strings
|
||||
*/
|
||||
public static $permissionLangPrefix = 'perm_content_';
|
||||
public static string $permissionLangPrefix = 'perm_content_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$titleLangPrefix}_{$id}" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'content_db_';
|
||||
public static ?string $titleLangPrefix = 'content_db_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Description suffix. If specified, will look for a language key with "{$titleLangPrefix}_{$id}_{$descriptionLangSuffix}" as the key
|
||||
*/
|
||||
public static $descriptionLangSuffix = 'desc';
|
||||
public static ?string $descriptionLangSuffix = 'desc';
|
||||
}
|
||||
Reference in new issue
Block a user