summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-29 13:57:26 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-29 13:57:26 +0100
commit3d94c3dfe203edeb25b42466733672aff9fca89f (patch)
treebe8aaf92d49b2f825a1da88c847e9c013da2d71a
parent2fb898ce714e282f5dfca365fe52abc15437f7ef (diff)
downloadliberty-3d94c3dfe203edeb25b42466733672aff9fca89f.tar.gz
liberty-3d94c3dfe203edeb25b42466733672aff9fca89f.tar.bz2
liberty-3d94c3dfe203edeb25b42466733672aff9fca89f.zip
BOM parts list support: xref template dispatch and LibertyXref fixes
- LibertyContent: add getXrefListTemplate(), getXrefRecordTemplate(), getXrefEditTemplate() for package-aware template dispatch with liberty fallback - LibertyXref: explicit xorder passthrough in verify(); fix start_date/end_date to use time() instead of mDb->NOW() so BitDate::date() receives a timestamp - add_xref.php, edit_xref.php: redirect to getEditUrl() after save/cancel - list_xref.tpl: use getXrefRecordTemplate() instead of hardcoded liberty path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--add_xref.php5
-rw-r--r--edit_xref.php9
-rwxr-xr-xincludes/classes/LibertyContent.php37
-rw-r--r--includes/classes/LibertyXref.php7
-rw-r--r--templates/list_xref.tpl2
5 files changed, 50 insertions, 10 deletions
diff --git a/add_xref.php b/add_xref.php
index 89c7908..fcf0ffc 100644
--- a/add_xref.php
+++ b/add_xref.php
@@ -6,6 +6,7 @@
namespace Bitweaver\Liberty;
+
require_once '../kernel/includes/setup_inc.php';
global $gBitSystem, $gBitSmarty, $gBitUser, $gContent;
@@ -23,13 +24,13 @@ if( !$gContent || !$gContent->isValid() ) {
$gContent->verifyUpdatePermission();
if( !empty( $_REQUEST['fCancel'] ) ) {
- header( 'Location: '.$gContent->getDisplayUrl() );
+ header( 'Location: '.$gContent->getEditUrl() );
die;
}
if( !empty( $_REQUEST['fAddXref'] ) ) {
if( $gContent->storeXref( $_REQUEST ) ) {
- header( 'Location: '.$gContent->getDisplayUrl() );
+ header( 'Location: '.$gContent->getEditUrl() );
die;
}
}
diff --git a/edit_xref.php b/edit_xref.php
index 2c14384..b58044a 100644
--- a/edit_xref.php
+++ b/edit_xref.php
@@ -25,14 +25,14 @@ if( !empty( $_REQUEST['xref_id'] ) ) {
}
if( !empty( $_REQUEST['fCancel'] ) ) {
- header( 'Location: '.$gContent->getDisplayUrl() );
+ header( 'Location: '.$gContent->getEditUrl() );
die;
}
if( !empty( $_REQUEST['fSaveXref'] ) ) {
$gContent->verifyUpdatePermission();
if( $gContent->storeXref( $_REQUEST ) ) {
- header( 'Location: '.$gContent->getDisplayUrl() );
+ header( 'Location: '.$gContent->getEditUrl() );
die;
}
$xrefInfo = $_REQUEST;
@@ -40,7 +40,7 @@ if( !empty( $_REQUEST['fSaveXref'] ) ) {
} elseif( isset( $_REQUEST['expunge'] ) ) {
$gContent->verifyExpungePermission();
if( $gContent->stepXref( $_REQUEST ) ) {
- header( 'Location: '.$gContent->getDisplayUrl() );
+ header( 'Location: '.$gContent->getEditUrl() );
die;
}
$xrefInfo = $gContent->mInfo['xref_store']['data'] ?? [];
@@ -53,4 +53,5 @@ $gBitSmarty->assign( 'gContent', $gContent );
$gBitSmarty->assign( 'xrefInfo', $xrefInfo );
$gBitSmarty->assign( 'errors', $gContent->mErrors );
-$gBitSystem->display( 'bitpackage:liberty/edit_xref.tpl', 'Edit Detail', [ 'display_mode' => 'edit' ] );
+$xrefTemplate = $gContent->mInfo['xref_store']['data']['template'] ?? 'text';
+$gBitSystem->display( $gContent->getXrefEditTemplate( $xrefTemplate ), 'Edit Detail', [ 'display_mode' => 'edit' ] );
diff --git a/includes/classes/LibertyContent.php b/includes/classes/LibertyContent.php
index 99659e0..9f79e45 100755
--- a/includes/classes/LibertyContent.php
+++ b/includes/classes/LibertyContent.php
@@ -2155,6 +2155,43 @@ class LibertyContent extends LibertyBase implements BitCacheable {
* @param number $pContentId a valid content id
* @param array $pMixed a hash of params to add to the url
*/
+ public function getXrefListTemplate( ?string $pTemplate = null ): string {
+ if( $pTemplate ) {
+ $package = $this->mType['handler_package'] ?? 'liberty';
+ $pkgConst = strtoupper( $package ).'_PKG_PATH';
+ if( defined( $pkgConst ) && file_exists( constant( $pkgConst ).'templates/list_xref_'.$pTemplate.'.tpl' ) ) {
+ return 'bitpackage:'.$package.'/list_xref_'.$pTemplate.'.tpl';
+ }
+ }
+ return 'bitpackage:liberty/list_xref.tpl';
+ }
+
+ public function getXrefRecordTemplate( ?string $pTemplate = null ): string {
+ $pTemplate = $pTemplate ?: 'text';
+ $package = $this->mType['handler_package'] ?? 'liberty';
+ $pkgConst = strtoupper( $package ).'_PKG_PATH';
+ if( defined( $pkgConst ) ) {
+ $pkgTpl = constant( $pkgConst ).'templates/view_xref_'.$pTemplate.'_record.tpl';
+ if( file_exists( $pkgTpl ) ) {
+ return 'bitpackage:'.$package.'/view_xref_'.$pTemplate.'_record.tpl';
+ }
+ }
+ return 'bitpackage:liberty/view_xref_'.$pTemplate.'_record.tpl';
+ }
+
+ public function getXrefEditTemplate( ?string $pTemplate = null ): string {
+ $pTemplate = $pTemplate ?: 'text';
+ $package = $this->mType['handler_package'] ?? 'liberty';
+ $pkgConst = strtoupper( $package ).'_PKG_PATH';
+ if( defined( $pkgConst ) ) {
+ $pkgTpl = constant( $pkgConst ).'templates/edit_xref_'.$pTemplate.'.tpl';
+ if( file_exists( $pkgTpl ) ) {
+ return 'bitpackage:'.$package.'/edit_xref_'.$pTemplate.'.tpl';
+ }
+ }
+ return 'bitpackage:liberty/edit_xref.tpl';
+ }
+
public function getEditUrl( $pContentId = null, $pMixed = null ){
global $gLibertySystem;
$package = $gLibertySystem->mContentTypes[$this->mType['content_type_guid']]['handler_package'];
diff --git a/includes/classes/LibertyXref.php b/includes/classes/LibertyXref.php
index 5327351..2473507 100644
--- a/includes/classes/LibertyXref.php
+++ b/includes/classes/LibertyXref.php
@@ -92,7 +92,7 @@ class LibertyXref extends LibertyBase {
$pParamHash['xref_store']['item'] = $this->mItem;
$pParamHash['xref_store']['xorder'] = $this->mInfo['data']['xorder'] + 1;
$pParamHash['xref_store']['content_id'] = $this->mContentId;
- $pParamHash['start_date'] = $this->mDb->NOW();
+ $pParamHash['start_date'] = time();
$pParamHash['ignore_end_date'] = 'on';
$pParamHash['xref_store']['xref'] = 0;
$pParamHash['xref_store']['xkey'] = '';
@@ -100,6 +100,7 @@ class LibertyXref extends LibertyBase {
$pParamHash['xref_store']['data'] = '';
}
+ if( isset( $pParamHash['xorder'] ) ) { $pParamHash['xref_store']['xorder'] = (int)$pParamHash['xorder']; }
if( isset( $pParamHash['xref'] ) ) { $pParamHash['xref_store']['xref'] = $pParamHash['xref']; }
if( isset( $pParamHash['xkey'] ) ) { $pParamHash['xref_store']['xkey'] = $pParamHash['xkey']; }
if( isset( $pParamHash['xkey_ext'] ) ) { $pParamHash['xref_store']['xkey_ext'] = $pParamHash['xkey_ext']; }
@@ -163,13 +164,13 @@ class LibertyXref extends LibertyBase {
if( isset( $pParamHash["expunge"] ) ) {
switch( $pParamHash["expunge"] ) {
case 2:
- $pParamHash['end_date'] = $this->mDb->NOW();
+ $pParamHash['end_date'] = time();
$this->store( $pParamHash );
unset( $pParamHash['xref_id'] );
$pParamHash['fStepXref'] = 1;
break;
case 1:
- $pParamHash['end_date'] = $this->mDb->NOW();
+ $pParamHash['end_date'] = time();
break;
default:
$pParamHash['ignore_end_date'] = 'on';
diff --git a/templates/list_xref.tpl b/templates/list_xref.tpl
index 9ac5a3e..a670111 100644
--- a/templates/list_xref.tpl
+++ b/templates/list_xref.tpl
@@ -22,7 +22,7 @@
<tbody>
{section name=xref loop=$gContent->mInfo.$source}
<tr class="{cycle values="even,odd"}">
- {include file="bitpackage:liberty/view_xref_`$gContent->mInfo.$source[xref].template`_record.tpl"}
+ {include file=$gContent->getXrefRecordTemplate($gContent->mInfo.$source[xref].template)}
</tr>
{sectionelse}
<tr class="norecords">