summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-22 15:44:44 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-22 15:44:44 +0100
commit572b562f433532429423a5ccace64838efec93c7 (patch)
tree2c7a9dbe8570578a58d5b396a15388243628ffda /includes
parent825ce764d0e6bcdcaccad653a346e03a25cd267f (diff)
downloadliberty-572b562f433532429423a5ccace64838efec93c7.tar.gz
liberty-572b562f433532429423a5ccace64838efec93c7.tar.bz2
liberty-572b562f433532429423a5ccace64838efec93c7.zip
Add generic xref group/source admin pages to liberty
LibertyXrefType: add getContentTypeGuids() and getGroupList() static methods. New admin pages with package filter (session-persisted content_type_guid dropdown): admin_xref_groups.php manages liberty_xref_type rows; admin_xref_sources.php manages liberty_xref_source rows. Both support add and delete (delete guarded by entry/source count). Wired into menu_liberty_admin.tpl as Xref Groups / Xref Sources links. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
-rw-r--r--includes/classes/LibertyXrefType.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/includes/classes/LibertyXrefType.php b/includes/classes/LibertyXrefType.php
index 321db07..00f2cb2 100644
--- a/includes/classes/LibertyXrefType.php
+++ b/includes/classes/LibertyXrefType.php
@@ -50,4 +50,46 @@ class LibertyXrefType extends LibertyBase {
return $ret;
}
+
+ /**
+ * Returns the distinct content_type_guid values present in liberty_xref_type.
+ */
+ public static function getContentTypeGuids(): array {
+ global $gBitSystem;
+ $result = $gBitSystem->mDb->query(
+ "SELECT DISTINCT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_xref_type` ORDER BY `content_type_guid`",
+ []
+ );
+ $ret = [];
+ while ( $res = $result->fetchRow() ) {
+ $ret[] = $res['content_type_guid'];
+ }
+ return $ret;
+ }
+
+ /**
+ * Returns liberty_xref_type rows, optionally filtered by content_type_guid.
+ * Each row includes num_sources: count of sources defined for that group.
+ */
+ public static function getGroupList( $pOptionHash = NULL ): array {
+ global $gBitSystem;
+ $where = '';
+ $bindVars = [];
+ if ( !empty( $pOptionHash['content_type_guid'] ) ) {
+ $where = " WHERE cxt.`content_type_guid` = ?";
+ $bindVars[] = $pOptionHash['content_type_guid'];
+ }
+ $query = "SELECT cxt.* FROM `".BIT_DB_PREFIX."liberty_xref_type` cxt
+ $where ORDER BY cxt.`content_type_guid`, cxt.`sort_order`";
+ $result = $gBitSystem->mDb->query( $query, $bindVars );
+ $ret = [];
+ while ( $res = $result->fetchRow() ) {
+ $res['num_sources'] = $gBitSystem->mDb->getOne(
+ "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_source` WHERE `xref_type` = ? AND `content_type_guid` = ?",
+ [ $res['xref_type'], $res['content_type_guid'] ]
+ );
+ $ret[] = $res;
+ }
+ return $ret;
+ }
}