diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-21 19:26:26 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-21 19:26:26 +0100 |
| commit | 4ba9b3906b27e3571767689d2764b67dfe007e30 (patch) | |
| tree | 494f4e6a65d34a4338c14de4144595a2df8c65b5 /admin | |
| download | stock-4ba9b3906b27e3571767689d2764b67dfe007e30.tar.gz stock-4ba9b3906b27e3571767689d2764b67dfe007e30.tar.bz2 stock-4ba9b3906b27e3571767689d2764b67dfe007e30.zip | |
Initial stock package — forked from fisheye
StockAssembly (was FisheyeGallery), StockComponent (was FisheyeImage),
StockBase (was FisheyeBase). All fisheye_ table prefixes and FISHEYE_
constants renamed to stock_/STOCK_. DB schema will need rework before
install; this gives a non-clashing base to diverge from fisheye.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'admin')
| -rwxr-xr-x | admin/admin_stock_inc.php | 180 | ||||
| -rwxr-xr-x | admin/schema_inc.php | 109 |
2 files changed, 289 insertions, 0 deletions
diff --git a/admin/admin_stock_inc.php b/admin/admin_stock_inc.php new file mode 100755 index 0000000..22ca15f --- /dev/null +++ b/admin/admin_stock_inc.php @@ -0,0 +1,180 @@ +<?php + +use Bitweaver\KernelTools; + +//This holds the checkbox options for what to display on the 'list galleries' page +$formGalleryGeneral = [ + "stock_menu_text" => [ + 'label' => 'Menu Text', + 'note' => '', + 'type' => 'text', + ], +/* Disabled for now - spiderr + "feature_megaupload" => [ + 'label' => 'Use <a href="http://sourceforge.net/projects/megaupload">MegaUpload</a>', + 'note' => 'Upload progress meter that requires Perl and ExecCGI permission', + 'type' => 'checkbox' + ], +*/ + "liberty_offline_thumbnailer" => [ + 'label' => 'Background Thumbnailer', + 'note' => 'Thumbnails will be queued and regenerated by a background command-line script. For more information, see '.STOCK_PKG_PATH.'thumbaniler.php or you can <a href="'.STOCK_PKG_URL.'thumbnailer.php">run it manually</a>', + 'type' => 'checkbox', + ], + "stock_show_public_on_upload" => [ + 'label' => 'Show Public Galleries on Upload', + 'note' => 'Enable this if you want to have all public galleries visible when uploading files. This might cause problems on large sites with many public galleries.', + 'type' => 'checkbox', + ], + "stock_show_all_to_admins" => [ + 'label' => 'Show all Galleries to Administrators', + 'note' => 'This will allow gallery admins to upload and move around images in all galleries. This might cause problems on large sites with many galleries.', + 'type' => 'checkbox', + ], +]; +if( !$gBitSystem->isPackageActive( 'gigaupload' ) ) { + $formGalleryGeneral["stock_extended_upload_slots"] = [ + 'label' => 'Extended Upload Slots', + 'note' => 'When you enable this, users can enter the title and description of the file when uploading them.', + 'type' => 'checkbox', + ]; +}; +$gBitSmarty->assign('formGalleryGeneral', $formGalleryGeneral); + +$formGalleryListLists = [ + "stock_list_title" => [ + 'label' => 'Gallery title', + 'note' => 'List the title of the gallery.', + ], + "stock_list_thumbnail" => [ + 'label' => 'Thumbnail', + 'note' => 'Display a small thumbnail associated with a gallery', + ], + "stock_list_description" => [ + 'label' => 'Description', + 'note' => 'List the description of a gallery', + ], + "stock_list_user" => [ + 'label' => 'Creator', + 'note' => 'List the name of the user who created the gallery', + ], + "stock_list_hits" => [ + 'label' => 'Hits', + 'note' => 'List number of hits this gallery has receieved', + ], + "stock_list_created" => [ + 'label' => 'Creation date', + 'note' => 'List the creation date of the gallery', + ], + "stock_list_lastmodif" => [ + 'label' => 'Last modification', + 'note' => 'List date this gallery was last modified', + ], +]; +$gBitSmarty->assign('formGalleryListLists', $formGalleryListLists); + +// This holds the checkbox options for what to display on a 'view gallery' page +$formGalleryLists = [ + "stock_gallery_list_title" => [ + 'label' => 'Gallery title', + 'note' => 'When viewing a gallery, display the title of the gallery', + ], + "stock_gallery_list_description" => [ + 'label' => 'Gallery description', + 'note' => 'When viewing a gallery, display the description of the gallery below the title', + ], + "stock_gallery_list_image_titles" => [ + 'label' => 'Image titles', + 'note' => 'Show image titles underneath each thumbnail', + ], + "stock_gallery_hide_modules" => [ + 'label' => 'Hide modules for galleries', + 'note' => 'When viewing a gallery, hide the left and right module columns', + ], + "stock_gallery_list_image_descriptions" => [ + 'label' => 'Image description', + 'note' => 'Show image descriptions underneath each thumbnail', + ], + "stock_gallery_div_layout" => [ + 'label' => '<div> based Layout', + 'note' => 'You can use a <div> based layout, which will adjust the number of images in each row to the width of the browser. Please visit the online help for more information.', + 'page' => 'StockPackage', + ], +]; +$gBitSmarty->assign( 'formGalleryLists',$formGalleryLists ); + +// This holds the checkbox options for what to display on an 'image details' page +$formImageLists = [ + "stock_image_list_title" => [ + 'label' => 'Image title', + 'note' => 'When viewing an image, display the title of the image', + ], + "stock_image_list_description" => [ + 'label' => 'Image description', + 'note' => 'When viewing an image, display the description of the image below the title', + ], + "stock_image_hide_modules" => [ + 'label' => 'Hide modules for images', + 'note' => 'When viewing an image, hide the left and right module columns', + ], + "gallerybar_use_icons" => [ + 'label' => 'Use icons in the gallery bar', + 'note' => 'When viewing an image, show <strong>previous</strong> and <strong>next</strong> links as images instead of words', + ], + "gallery_bar_use_thumbnails" => [ + 'label' => 'Use Thumbnails in gallery bar', + 'note' => 'When viewing an image, show previous and next <strong>thumbnails</strong> with the appropriate links.', + ], +]; +$gBitSmarty->assign( 'formImageLists', $formImageLists); + +use Bitweaver\Stock\StockAssembly; + +$gBitSmarty->assign( 'galleryPaginationTypes', StockAssembly::getAllLayouts() ); + +$sortOptions = [ + '' => KernelTools::tra( 'None' ), + 'lc.title_desc' => KernelTools::tra( 'Image Title' ). ' - '.KernelTools::tra( 'descending' ), + 'lc.title_asc' => KernelTools::tra( 'Image Title' ). ' - '.KernelTools::tra( 'ascending' ), + 'lc.created_desc' => KernelTools::tra( 'Date Uploaded' ).' - '.KernelTools::tra( 'descending' ), + 'lc.created_asc' => KernelTools::tra( 'Date Uploaded' ).' - '.KernelTools::tra( 'ascending' ), + 'lc.last_modified_desc' => KernelTools::tra( 'Last Modified' ).' - '.KernelTools::tra( 'descending' ), + 'lc.last_modified_asc' => KernelTools::tra( 'Last Modified' ).' - '.KernelTools::tra( 'ascending' ), +]; +$gBitSmarty->assign( 'sortOptions', $sortOptions ); +$gBitSmarty->assign( 'imageSizes', Bitweaver\Liberty\get_image_size_options( false )); + +//vd($_REQUEST); +if (!empty($_REQUEST['stockAdminSubmit'])) { + // General Settings + foreach ($formGalleryGeneral as $item=>$data) { + if( $data['type'] == 'checkbox' ) { + simple_set_toggle($item, STOCK_PKG_NAME); + } else { + $gBitSystem->storeConfig($item, $_REQUEST[$item], STOCK_PKG_NAME ); + } + } + + // Gallery List Display Settings + foreach ($formGalleryListLists as $item=>$data) { + simple_set_toggle($item, STOCK_PKG_NAME); + } + + // Gallery Display Settings + foreach ($formGalleryLists as $item => $data) { + simple_set_toggle($item, STOCK_PKG_NAME); + } + + foreach( [ 'stock_list_thumbnail_size', 'stock_gallery_default_thumbnail_size', 'default_gallery_pagination', 'rows_per_page', 'cols_per_page', 'total_per_page', 'lines_per_page', 'galleriffic_style', 'stock_gallery_default_sort_mode' ] as $key ) { + $gBitSystem->storeConfig($key, $_REQUEST[$key], STOCK_PKG_NAME); + } + + // Image Display Settings + foreach ($formImageLists as $item => $data) { + simple_set_toggle( $item, STOCK_PKG_NAME ); + } + if( !empty( $_REQUEST['default_image_thumbnail_size'] ) ) { + $gBitSystem->storeConfig('stock_image_default_thumbnail_size', $_REQUEST['default_image_thumbnail_size'], STOCK_PKG_NAME ); + } + +} diff --git a/admin/schema_inc.php b/admin/schema_inc.php new file mode 100755 index 0000000..8491977 --- /dev/null +++ b/admin/schema_inc.php @@ -0,0 +1,109 @@ +<?php + +$tables = [ + +'stock_gallery' => " + gallery_id I4 PRIMARY, + content_id I4, + rows_per_page I4, + cols_per_page I4, + thumbnail_size C(32), + preview_content_id I4, + image_comment C(1) +", + +'stock_gallery_image_map' => " + gallery_content_id I4 NOTNULL, + item_content_id I4 NOTNULL, + item_position F +", + +'stock_image' => " + image_id I4 PRIMARY, + content_id I4 NOTNULL, + photo_date I8, + width I4, + height I4 +", +]; + +global $gBitInstaller; + +foreach( array_keys( $tables ) AS $tableName ) { + $gBitInstaller->registerSchemaTable( STOCK_PKG_NAME, $tableName, $tables[$tableName] ); +} + +$indices = [ + 'stock_gallery_id_idx' => [ 'table' => 'stock_gallery', 'cols' => 'gallery_id', 'opts' => null ], + 'stock_gallery_content_idx' => [ 'table' => 'stock_gallery', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], + 'stock_image_id_idx' => [ 'table' => 'stock_image', 'cols' => 'image_id', 'opts' => null ], + 'stock_image_content_idx' => [ 'table' => 'stock_image', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ], +]; +$gBitInstaller->registerSchemaIndexes( STOCK_PKG_NAME, $indices ); + +$gBitInstaller->registerPackageInfo( STOCK_PKG_NAME, [ + 'description' => "FishEye is a package for creating image galleries", + 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', +] ); + +// ### Sequences +$sequences = [ + 'stock_gallery_id_seq' => [ 'start' => 1 ], + 'stock_image_id_seq' => [ 'start' => 1 ], +]; +$gBitInstaller->registerSchemaSequences( STOCK_PKG_NAME, $sequences ); + +// ### Default Preferences +$gBitInstaller->registerPreferences( STOCK_PKG_NAME, [ + [ STOCK_PKG_NAME, 'stock_list_title','y'], + [ STOCK_PKG_NAME, 'stock_list_created','y'], + [ STOCK_PKG_NAME, 'stock_list_user','y'], + [ STOCK_PKG_NAME, 'stock_list_hits','y'], + [ STOCK_PKG_NAME, 'stock_list_thumbnail','y'], + [ STOCK_PKG_NAME, 'stock_list_thumbnail_size','small'], + [ STOCK_PKG_NAME, 'stock_gallery_list_title','y'], + [ STOCK_PKG_NAME, 'stock_gallery_list_description','y'], + [ STOCK_PKG_NAME, 'stock_gallery_list_image_titles','y'], + [ STOCK_PKG_NAME, 'stock_gallery_default_rows_per_page','5'], + [ STOCK_PKG_NAME, 'stock_gallery_default_cols_per_page','3'], + [ STOCK_PKG_NAME, 'stock_gallery_default_thumbnail_size','small'], + [ STOCK_PKG_NAME, 'stock_image_list_title','y'], + [ STOCK_PKG_NAME, 'stock_image_list_description','y'], + [ STOCK_PKG_NAME, 'stock_image_default_thumbnail_size','medium'], + [ STOCK_PKG_NAME, 'stock_menu_text','Image Galleries'], + // more intuitive if we can see all galleries we can upload images to + [ STOCK_PKG_NAME, 'stock_show_public_on_upload','n'], + [ STOCK_PKG_NAME, 'stock_show_all_to_admins','n'], +] ); + +// ### Default User Permissions +$gBitInstaller->registerUserPermissions( STOCK_PKG_NAME, [ + ['p_stock_list_galleries', 'Can list image galleries', 'basic', STOCK_PKG_NAME], + ['p_stock_view', 'Can view image galleries', 'basic', STOCK_PKG_NAME], + ['p_stock_create', 'Can create an image gallery', 'registered', STOCK_PKG_NAME], + ['p_stock_update', 'Can update image gallery', 'editors', STOCK_PKG_NAME], + ['p_stock_upload', 'Can upload images to gallery', 'registered', STOCK_PKG_NAME], + ['p_stock_admin', 'Can admin image galleries', 'editors', STOCK_PKG_NAME], + ['p_stock_upload_nonimages', 'Can upload non_image files', 'editors', STOCK_PKG_NAME], + ['p_stock_change_thumb_size', 'Can set the thumbnail size for a gallery', 'editors', STOCK_PKG_NAME], + ['p_stock_create_public_gal', 'Can create public galleries any user can load images into', 'editors', STOCK_PKG_NAME], + ['p_stock_download_gallery_arc',' Can download an archived copy of Stock gallery', 'registered', STOCK_PKG_NAME], +] ); + +if( defined( 'RSS_PKG_NAME' )) { + $gBitInstaller->registerPreferences( STOCK_PKG_NAME, [ + [ RSS_PKG_NAME, STOCK_PKG_NAME.'_rss', 'y'], + ]); +} + +// ### Register content types +$gBitInstaller->registerContentObjects( STOCK_PKG_NAME, [ + 'StockAssembly'=>STOCK_PKG_CLASS_PATH.'StockAssembly.php', + 'StockComponent'=>STOCK_PKG_CLASS_PATH.'StockComponent.php', +] ); + +// Requirements +$gBitInstaller->registerRequirements( STOCK_PKG_NAME, [ + 'liberty' => [ 'min' => '5.0.0' ], +]); + |
