use latest Database namespace
This commit is contained in:
parent
78f131f038
commit
6af93533c4
@ -16,7 +16,7 @@ namespace Dotclear\Plugin\enhancePostContent;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcRecord;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
use Exception;
|
||||
|
||||
@ -30,8 +30,8 @@ abstract class EpcFilter
|
||||
/** @var string $id The filter id */
|
||||
protected string $id = 'undefined';
|
||||
|
||||
/** @var dcRecord $records The filter record if any */
|
||||
private ?dcRecord $records = null;
|
||||
/** @var MetaRecord $records The filter record if any */
|
||||
private ?MetaRecord $records = null;
|
||||
|
||||
/** @var int $priority The filter priority (property) */
|
||||
public readonly int $priority;
|
||||
@ -155,15 +155,15 @@ abstract class EpcFilter
|
||||
* Fitler records are usefull to store and retrieve
|
||||
* list of keyword / replacement etc...
|
||||
*
|
||||
* @return dcRecord The filter record instance
|
||||
* @return MetaRecord The filter record instance
|
||||
*/
|
||||
final public function records(): dcRecord
|
||||
final public function records(): MetaRecord
|
||||
{
|
||||
if ($this->records === null && $this->has_list) {
|
||||
$this->records = EpcRecord::getRecords(['epc_filter' => $this->id()]);
|
||||
}
|
||||
|
||||
return $this->records ?? dcRecord::newFromArray([]);
|
||||
return $this->records ?? MetaRecord::newFromArray([]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,9 +14,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\enhancePostContent;
|
||||
|
||||
use cursor;
|
||||
use dcCore;
|
||||
use dcRecord;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
};
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@ -30,9 +32,9 @@ class EpcRecord
|
||||
* @param array $params The query params
|
||||
* @param bool $count_only Count only
|
||||
*
|
||||
* @return dcRecord The records instance
|
||||
* @return MetaRecord The records instance
|
||||
*/
|
||||
public static function getRecords(array $params, bool $count_only = false): dcRecord
|
||||
public static function getRecords(array $params, bool $count_only = false): MetaRecord
|
||||
{
|
||||
if ($count_only) {
|
||||
$strReq = 'SELECT count(E.epc_id) ';
|
||||
@ -107,17 +109,17 @@ class EpcRecord
|
||||
$strReq .= dcCore::app()->con->limit($params['limit']);
|
||||
}
|
||||
|
||||
return new dcRecord(dcCore::app()->con->select($strReq));
|
||||
return new MetaRecord(dcCore::app()->con->select($strReq));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add record.
|
||||
*
|
||||
* @param cursor $cur The cursor
|
||||
* @param Cursor $cur The Cursor
|
||||
*
|
||||
* @return int The record ID
|
||||
*/
|
||||
public static function addRecord(cursor $cur): int
|
||||
public static function addRecord(Cursor $cur): int
|
||||
{
|
||||
dcCore::app()->con->writeLock(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
|
||||
@ -137,7 +139,7 @@ class EpcRecord
|
||||
}
|
||||
dcCore::app()->blog?->triggerBlog();
|
||||
|
||||
# --BEHAVIOR-- enhancePostContentAfterAddRecord : cursor
|
||||
# --BEHAVIOR-- enhancePostContentAfterAddRecord : Cursor
|
||||
dcCore::app()->callBehavior('enhancePostContentAfterAddRecord', $cur);
|
||||
|
||||
return (int) $cur->getField('epc_id');
|
||||
@ -147,9 +149,9 @@ class EpcRecord
|
||||
* Update a record.
|
||||
*
|
||||
* @param int $id The record ID
|
||||
* @param cursor $cur The cursor
|
||||
* @param Cursor $cur The Cursor
|
||||
*/
|
||||
public static function updRecord(int $id, cursor $cur): void
|
||||
public static function updRecord(int $id, Cursor $cur): void
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new Exception(__('No such record ID'));
|
||||
@ -160,7 +162,7 @@ class EpcRecord
|
||||
$cur->update('WHERE epc_id = ' . $id . " AND blog_id = '" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog?->id) . "' ");
|
||||
dcCore::app()->blog?->triggerBlog();
|
||||
|
||||
# --BEHAVIOR-- enhancePostContentAfterUpdRecord : cursor, int
|
||||
# --BEHAVIOR-- enhancePostContentAfterUpdRecord : Cursor, int
|
||||
dcCore::app()->callBehavior('enhancePostContentAfterUpdRecord', $cur, $id);
|
||||
}
|
||||
|
||||
@ -218,21 +220,21 @@ class EpcRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* Open filter cursor.
|
||||
* Open filter Cursor.
|
||||
*
|
||||
* @return cursor The cursor
|
||||
* @return Cursor The Cursor
|
||||
*/
|
||||
public static function openCursor(): cursor
|
||||
public static function openCursor(): Cursor
|
||||
{
|
||||
return dcCore::app()->con->openCursor(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up a cursor.
|
||||
* Clean up a Cursor.
|
||||
*
|
||||
* @param cursor $cur The cursor
|
||||
* @param Cursor $cur The Cursor
|
||||
*/
|
||||
private static function getCursor(cursor $cur): void
|
||||
private static function getCursor(Cursor $cur): void
|
||||
{
|
||||
if ($cur->getField('epc_key') == '') {
|
||||
throw new Exception(__('No record key'));
|
||||
|
@ -14,10 +14,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\enhancePostContent;
|
||||
|
||||
use dbStruct;
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
class Install extends dcNsProcess
|
||||
@ -39,15 +39,15 @@ class Install extends dcNsProcess
|
||||
|
||||
try {
|
||||
// Database
|
||||
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s->{My::TABLE_NAME}
|
||||
->epc_id('bigint', 0, false)
|
||||
->blog_id('varchar', 32, false)
|
||||
->epc_type('varchar', 32, false, "'epc'")
|
||||
->epc_filter('varchar', 64, false)
|
||||
->epc_key('varchar', 255, false)
|
||||
->epc_value('text', 0, false)
|
||||
->epc_upddt('timestamp', 0, false, 'now()')
|
||||
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s->__get(My::TABLE_NAME)
|
||||
->field('epc_id', 'bigint', 0, false)
|
||||
->field('blog_id', 'varchar', 32, false)
|
||||
->field('epc_type', 'varchar', 32, false, "'epc'")
|
||||
->field('epc_filter', 'varchar', 64, false)
|
||||
->field('epc_key', 'varchar', 255, false)
|
||||
->field('epc_value', 'text', 0, false)
|
||||
->field('epc_upddt', 'timestamp', 0, false, 'now()')
|
||||
|
||||
->primary('pk_epc', 'epc_id')
|
||||
->index('idx_epc_blog_id', 'btree', 'blog_id')
|
||||
@ -55,7 +55,7 @@ class Install extends dcNsProcess
|
||||
->index('idx_epc_filter', 'btree', 'epc_filter')
|
||||
->index('idx_epc_key', 'btree', 'epc_key');
|
||||
|
||||
(new dbStruct(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||
$s = null;
|
||||
|
||||
// Uppgrade
|
||||
|
Loading…
Reference in New Issue
Block a user