diff options
Diffstat (limited to 'core/namespace/Page')
-rw-r--r-- | core/namespace/Page/Attribute.php | 22 | ||||
-rw-r--r-- | core/namespace/Page/Entity.php | 13 | ||||
-rw-r--r-- | core/namespace/Page/Exception.php | 4 | ||||
-rw-r--r-- | core/namespace/Page/Factory.php | 4 | ||||
-rw-r--r-- | core/namespace/Page/Item.php | 20 | ||||
-rw-r--r-- | core/namespace/Page/Repository.php | 17 |
6 files changed, 30 insertions, 50 deletions
diff --git a/core/namespace/Page/Attribute.php b/core/namespace/Page/Attribute.php deleted file mode 100644 index 05eaa33..0000000 --- a/core/namespace/Page/Attribute.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -namespace Page; - -class Attribute extends \Attribute { - - #=============================================================================== - # Pre-Define database table columns - #=============================================================================== - protected $id = FALSE; - protected $user = FALSE; - protected $slug = FALSE; - protected $name = FALSE; - protected $body = FALSE; - protected $argv = FALSE; - protected $time_insert = FALSE; - protected $time_update = FALSE; - - #=============================================================================== - # Define database table name - #=============================================================================== - const TABLE = 'page'; -} diff --git a/core/namespace/Page/Entity.php b/core/namespace/Page/Entity.php new file mode 100644 index 0000000..6ca5979 --- /dev/null +++ b/core/namespace/Page/Entity.php @@ -0,0 +1,13 @@ +<?php +namespace Page; + +class Entity extends \Entity { + protected $id = FALSE; + protected $user = FALSE; + protected $slug = FALSE; + protected $name = FALSE; + protected $body = FALSE; + protected $argv = FALSE; + protected $time_insert = FALSE; + protected $time_update = FALSE; +} diff --git a/core/namespace/Page/Exception.php b/core/namespace/Page/Exception.php deleted file mode 100644 index c41bddc..0000000 --- a/core/namespace/Page/Exception.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -namespace Page; - -class Exception extends \Exception {} diff --git a/core/namespace/Page/Factory.php b/core/namespace/Page/Factory.php deleted file mode 100644 index 2fcc361..0000000 --- a/core/namespace/Page/Factory.php +++ /dev/null @@ -1,4 +0,0 @@ -<?php -namespace Page; - -class Factory extends \ItemFactory {} diff --git a/core/namespace/Page/Item.php b/core/namespace/Page/Item.php deleted file mode 100644 index cbc99e6..0000000 --- a/core/namespace/Page/Item.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -namespace Page; - -class Item extends \Item { - const CONFIGURATION = 'PAGE'; - - #=============================================================================== - # Return unique page IDs for search results - #=============================================================================== - public static function getSearchResultIDs($search, \Database $Database): array { - $Statement = $Database->prepare(sprintf("SELECT id FROM %s WHERE - MATCH(name, body) AGAINST(? IN BOOLEAN MODE) LIMIT 20", Attribute::TABLE)); - - if($Statement->execute([$search])) { - return $Statement->fetchAll($Database::FETCH_COLUMN); - } - - return []; - } -} diff --git a/core/namespace/Page/Repository.php b/core/namespace/Page/Repository.php new file mode 100644 index 0000000..b76ef85 --- /dev/null +++ b/core/namespace/Page/Repository.php @@ -0,0 +1,17 @@ +<?php +namespace Page; + +class Repository extends \Repository { + public static function getTableName(): string { return 'page'; } + public static function getClassName(): string { return 'Page\Entity'; } + + public function getCountByUser(\User\Entity $User): int { + $query = 'SELECT COUNT(id) FROM %s WHERE user = ?'; + $query = sprintf($query, static::getTableName()); + + $Statement = $this->Database->prepare($query); + $Statement->execute([$User->getID()]); + + return $Statement->fetchColumn(); + } +} |