diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-26 14:55:36 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-26 14:55:36 +0100 |
| commit | 70c559432ece25dd3def8c64ddb7c1908b4d49e0 (patch) | |
| tree | 9627e43fbe0d0eb082e4d54fa47773cda77e58f7 /liberty_plugins | |
| parent | 0579f237e179c8815c1c44d9c5cef94ad2a33588 (diff) | |
| download | stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.gz stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.tar.bz2 stock-70c559432ece25dd3def8c64ddb7c1908b4d49e0.zip | |
Add xref support, assembly/component views, and import tooling
- add_xref.php, edit_xref.php: xref record add/edit for stock content types
- admin xref group/source pages for stock_assembly and stock_component
- assembly_views/: auto_flow, fixed_grid, position_number, simple_list layouts
- Full assembly and component listing, tree, ordering, and detail pages
- Import tooling (ImportAssembly, ImportComponent, load scripts)
- liberty_plugins for assembly and component data types
- schema_inc.php updated; StockAssembly, StockBase, StockComponent,
StockMovement classes updated with xref group/item/multiple renames
- Templates updated throughout for xref rename (source→item, group→x_group)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'liberty_plugins')
| -rwxr-xr-x | liberty_plugins/data.assembly.php | 84 | ||||
| -rwxr-xr-x | liberty_plugins/data.component.php | 84 |
2 files changed, 168 insertions, 0 deletions
diff --git a/liberty_plugins/data.assembly.php b/liberty_plugins/data.assembly.php new file mode 100755 index 0000000..337eda6 --- /dev/null +++ b/liberty_plugins/data.assembly.php @@ -0,0 +1,84 @@ +<?php +/** + * @version $Revision$ + * $Header$ + * @package liberty + * @subpackage plugins_storage + */ + +namespace Bitweaver\Liberty; + +use Bitweaver\Stock\StockAssembly; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; + +define( 'PLUGIN_GUID_DATAASSEMBLY', 'dataassembly' ); + +global $gLibertySystem; + +$pluginParams = [ + 'tag' => 'assembly', + 'title' => 'Stock Assembly', + 'description' => KernelTools::tra( "Display a link to a stock assembly in other content." ), + 'help_page' => 'DataPluginAssembly', + + 'auto_activate' => false, + 'requires_pair' => false, + 'syntax' => '{assembly id= }', + 'plugin_type' => DATA_PLUGIN, + + 'booticon' => '{booticon iname="icon-list" iexplain="Assembly"}', + 'taginsert' => '{assembly id= nolink=}', + + 'help_function' => 'data_assembly_help', + 'load_function' => 'data_assembly', +]; +$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAASSEMBLY, $pluginParams ); +$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAASSEMBLY ); + +function data_assembly( $pData, $pParams ) { + global $gBitSystem; + $ret = ' '; + + if( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'stock' ) ) { + $assembly = new StockAssembly( null, $pParams['id'] ); + if( $assembly->load() ) { + $title = htmlspecialchars( $assembly->getTitle() ); + if( !empty( $pParams['nolink'] ) ) { + $ret = $title; + } else { + $url = htmlspecialchars( $assembly->getDisplayUrl() ); + $ret = '<a href="'.$url.'">'.$title.'</a>'; + } + } else { + $ret = KernelTools::tra( "Unknown Assembly" ); + } + } else { + $ret = KernelTools::tra( "Unknown Assembly" ); + } + + return $ret; +} + +function data_assembly_help() { + $help = + '<table class="data help">' + .'<tr>' + .'<th>' . KernelTools::tra( "Key" ) . '</th>' + .'<th>' . KernelTools::tra( "Type" ) . '</th>' + .'<th>' . KernelTools::tra( "Comments" ) . '</th>' + .'</tr>' + .'<tr class="odd">' + .'<td>id</td>' + .'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(required)") . '</td>' + .'<td>' . KernelTools::tra( "Assembly id number of the assembly to link to." ) . '</td>' + .'</tr>' + .'<tr class="even">' + .'<td>nolink</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "Display the assembly title without a hyperlink." ) . '</td>' + .'</tr>' + .'</table>' + . KernelTools::tra( "Example: ") . "{assembly id='5'}"; + return $help; +} diff --git a/liberty_plugins/data.component.php b/liberty_plugins/data.component.php new file mode 100755 index 0000000..438f7e5 --- /dev/null +++ b/liberty_plugins/data.component.php @@ -0,0 +1,84 @@ +<?php +/** + * @version $Revision$ + * $Header$ + * @package liberty + * @subpackage plugins_storage + */ + +namespace Bitweaver\Liberty; + +use Bitweaver\Stock\StockComponent; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; + +define( 'PLUGIN_GUID_DATACOMPONENT', 'datacomponent' ); + +global $gLibertySystem; + +$pluginParams = [ + 'tag' => 'component', + 'title' => 'Stock Component', + 'description' => KernelTools::tra( "Display a link to a component in other content." ), + 'help_page' => 'DataPluginComponent', + + 'auto_activate' => false, + 'requires_pair' => false, + 'syntax' => '{component id= }', + 'plugin_type' => DATA_PLUGIN, + + 'booticon' => '{booticon iname="icon-tag" iexplain="Component"}', + 'taginsert' => '{component id= nolink=}', + + 'help_function' => 'data_component_help', + 'load_function' => 'data_component', +]; +$gLibertySystem->registerPlugin( PLUGIN_GUID_DATACOMPONENT, $pluginParams ); +$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACOMPONENT ); + +function data_component( $pData, $pParams ) { + global $gBitSystem; + $ret = ' '; + + if( BitBase::verifyId( $pParams['id'] ) && $gBitSystem->isPackageActive( 'stock' ) ) { + $item = new StockComponent( $pParams['id'], null ); + if( $item->load() ) { + $title = htmlspecialchars( $item->getField( 'title', KernelTools::tra( 'Component' ) ) ); + if( !empty( $pParams['nolink'] ) ) { + $ret = $title; + } else { + $url = htmlspecialchars( $item->getDisplayUrl() ); + $ret = '<a href="'.$url.'">'.$title.'</a>'; + } + } else { + $ret = KernelTools::tra( "Unknown Component" ); + } + } else { + $ret = KernelTools::tra( "Unknown Component" ); + } + + return $ret; +} + +function data_component_help() { + $help = + '<table class="data help">' + .'<tr>' + .'<th>' . KernelTools::tra( "Key" ) . '</th>' + .'<th>' . KernelTools::tra( "Type" ) . '</th>' + .'<th>' . KernelTools::tra( "Comments" ) . '</th>' + .'</tr>' + .'<tr class="odd">' + .'<td>id</td>' + .'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(required)") . '</td>' + .'<td>' . KernelTools::tra( "Component id number of the component to link to." ) . '</td>' + .'</tr>' + .'<tr class="even">' + .'<td>nolink</td>' + .'<td>' . KernelTools::tra( "key-words") . '<br />' . KernelTools::tra("(optional)") . '</td>' + .'<td>' . KernelTools::tra( "Display the component title without a hyperlink." ) . '</td>' + .'</tr>' + .'</table>' + . KernelTools::tra( "Example: ") . "{component id='13'}"; + return $help; +} |
