diff options
| author | lsces <lester@lsces.co.uk> | 2026-02-01 17:57:53 +0000 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2026-02-01 17:57:53 +0000 |
| commit | 0b7bc39d45c39f36e13e704ac126f9246a9be62f (patch) | |
| tree | bed4210bdc7e2c43716ca3d42a44e9cbbc58780d /admin | |
| parent | e75480ed0929f12c69465d63aba1615db7b9436a (diff) | |
| download | articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.tar.gz articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.tar.bz2 articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.zip | |
Major refactor for namespace, php8.4 and smarty5
Diffstat (limited to 'admin')
| -rwxr-xr-x[-rw-r--r--] | admin/admin_articles_inc.php | 140 | ||||
| -rwxr-xr-x[-rw-r--r--] | admin/admin_topics.php | 8 | ||||
| -rwxr-xr-x[-rw-r--r--] | admin/admin_types.php | 113 | ||||
| -rwxr-xr-x[-rw-r--r--] | admin/index.php | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | admin/schema_inc.php | 114 | ||||
| -rw-r--r-- | admin/upgrade_inc.php | 393 | ||||
| -rw-r--r-- | admin/upgrades/1.0.0.php | 22 |
7 files changed, 190 insertions, 600 deletions
diff --git a/admin/admin_articles_inc.php b/admin/admin_articles_inc.php index 8b8ca69..956e163 100644..100755 --- a/admin/admin_articles_inc.php +++ b/admin/admin_articles_inc.php @@ -1,98 +1,100 @@ <?php + +use Bitweaver\KernelTools; // $Header$ // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See below for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. -$formCmsSettings = array( -/* - Feature is incomplete - 'articles_rankings' => array( - 'label' => 'Rankings', - 'note' => 'Activates statistics for article ranking features.', - ), -*/ - 'articles_attachments' => array( +$formCmsSettings = [ + /* + Feature is incomplete + 'articles_rankings' => [ + 'label' => 'Rankings', + 'note' => 'Activates statistics for article ranking features.', + ], + */ + 'articles_attachments' => [ 'label' => 'File Attachments', - 'note' => 'Allow the attachment of files to an article. This feature is required if you want to have individual article images.', - ), -/* 'articles_content_attachments' => array( - 'label' => 'Content Attachments', - 'note' => 'Allow the attachment of content to an article.', - ), -*/ - 'articles_display_filter_bar' => array( + 'note' => 'Allow the attachment of files to an article. This feature is required if you want to have individual article images.', + ], + /* 'articles_content_attachments' => [ + 'label' => 'Content Attachments', + 'note' => 'Allow the attachment of content to an article.', + ], + */ + 'articles_display_filter_bar' => [ 'label' => 'Articles Filter', - 'note' => 'Allows admins to quickly filter articles based on status, topic and type.', - ), - 'articles_submissions_rnd_img' => array( + 'note' => 'Allows admins to quickly filter articles based on status, topic and type.', + ], + 'articles_submissions_rnd_img' => [ 'label' => 'Prevent Spam', - 'note' => 'This will generate a random number as an image which the user has to confirm.', - ), - 'articles_auto_approve' => array( + 'note' => 'This will generate a random number as an image which the user has to confirm.', + ], + 'articles_auto_approve' => [ 'label' => 'Auto Approve Articles', - 'note' => 'Allow User ratings to Auto Approve Articles', - ), -); + 'note' => 'Allow User ratings to Auto Approve Articles', + ], +]; $gBitSmarty->assign( 'formCmsSettings',$formCmsSettings ); -$articleDateThreshold = array( - '' => tra( 'never' ), - 'always' => tra( 'always' ), - 'year' => tra( 'up to a year' ), - 'month' => tra( 'up to a month' ), - 'week' => tra( 'up to a week' ), - 'day' => tra( 'up to a day' ), - 'hour' => tra( 'up to an hour' ), -); +$articleDateThreshold = [ + '' => KernelTools::tra( 'never' ), + 'always' => KernelTools::tra( 'always' ), + 'year' => KernelTools::tra( 'up to a year' ), + 'month' => KernelTools::tra( 'up to a month' ), + 'week' => KernelTools::tra( 'up to a week' ), + 'day' => KernelTools::tra( 'up to a day' ), + 'hour' => KernelTools::tra( 'up to an hour' ), +]; $gBitSmarty->assign( 'articleDateThreshold', $articleDateThreshold ); -$formArticleListing = array( - "articles_list_title" => array( +$formArticleListing = [ + "articles_list_title" => [ 'label' => 'Title', - 'note' => 'List the title of the article.', - ), - "articles_list_type" => array( + 'note' => 'List the title of the article.', + ], + "articles_list_type" => [ 'label' => 'Type', - 'note' => 'Display what type of article it is.', - ), - "articles_list_topic" => array( + 'note' => 'Display what type of article it is.', + ], + "articles_list_topic" => [ 'label' => 'Topic', - 'note' => 'Display the article topic.', - ), - "articles_list_date" => array( + 'note' => 'Display the article topic.', + ], + "articles_list_date" => [ 'label' => 'Creation Date', - 'note' => 'Display when the article was submitted first.', - ), - "articles_list_expire" => array( + 'note' => 'Display when the article was submitted first.', + ], + "articles_list_expire" => [ 'label' => 'Expiration Date', - 'note' => 'Display when the article will expire.', - ), - "articles_list_author" => array( + 'note' => 'Display when the article will expire.', + ], + "articles_list_author" => [ 'label' => 'Author', - 'note' => 'Display the name of the author of an article.', - ), - "articles_list_reads" => array( + 'note' => 'Display the name of the author of an article.', + ], + "articles_list_reads" => [ 'label' => 'Hits', - 'note' => 'Display the number of times a given article has been accessed.', - ), - "articles_list_size" => array( + 'note' => 'Display the number of times a given article has been accessed.', + ], + "articles_list_size" => [ 'label' => 'Size', - 'note' => 'Display the size of any given article.', - ), - "articles_list_img" => array( + 'note' => 'Display the size of any given article.', + ], + "articles_list_img" => [ 'label' => 'Image', - 'note' => 'Display the image that is associated with a given article.', - ), - "articles_list_status" => array( + 'note' => 'Display the image that is associated with a given article.', + ], + "articles_list_status" => [ 'label' => 'Status', - 'note' => 'This will indicate whether a given article has been submitted or has been approved.', - ), -); + 'note' => 'This will indicate whether a given article has been submitted or has been approved.', + ], +]; $gBitSmarty->assign( 'formArticleListing', $formArticleListing ); -$gBitSmarty->assign( 'imageSizes', get_image_size_options( FALSE )); +$gBitSmarty->assign( 'imageSizes', \Bitweaver\Liberty\get_image_size_options( FALSE )); if( !empty( $_REQUEST['store_settings'] )) { - $featureToggles = array_merge( $formArticleListing,$formCmsSettings ); + $featureToggles = [ ...$formArticleListing,...$formCmsSettings ]; foreach( $featureToggles as $item => $data ) { simple_set_toggle( $item, ARTICLES_PKG_NAME ); } diff --git a/admin/admin_topics.php b/admin/admin_topics.php index 854c2dd..45ee77c 100644..100755 --- a/admin/admin_topics.php +++ b/admin/admin_topics.php @@ -1,8 +1,10 @@ <?php + // $Header$ require_once '../../kernel/includes/setup_inc.php'; +use Bitweaver\Articles\BitArticleTopic; +use Bitweaver\KernelTools; -include_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' ); include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_topic_inc.php' ); // Is package installed and enabled @@ -12,7 +14,7 @@ $gBitSystem->verifyPermission( 'p_articles_admin' ); if( isset( $_REQUEST["fSubmitAddTopic"] ) ) { $gContent->storeTopic( $_REQUEST ); if ( !empty( $gContent->mErrors ) ) { - $gBitSmarty->assignByRef('errors', $gContent->mErrors ); + $gBitSmarty->assign('errors', $gContent->mErrors ); } } elseif( !empty( $_REQUEST['fActivateTopic'] )&& $gContent ) { $gContent->activateTopic(); @@ -27,4 +29,4 @@ if( isset( $_REQUEST["fSubmitAddTopic"] ) ) { $topics = BitArticleTopic::getTopicList(); $gBitSmarty->assign( 'topics', $topics ); -$gBitSystem->display( 'bitpackage:articles/admin_topics.tpl', tra( 'Edit Topics' ) , array( 'display_mode' => 'admin' )); +$gBitSystem->display( 'bitpackage:articles/admin_topics.tpl', KernelTools::tra( 'Edit Topics' ) , [ 'display_mode' => 'admin' ]); diff --git a/admin/admin_types.php b/admin/admin_types.php index 3073b23..44e4a31 100644..100755 --- a/admin/admin_types.php +++ b/admin/admin_types.php @@ -1,9 +1,10 @@ <?php + // $Header$ require_once '../../kernel/includes/setup_inc.php'; -require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' ); -require_once( ARTICLES_PKG_CLASS_PATH.'BitArticleType.php' ); +use Bitweaver\KernelTools; +use Bitweaver\Articles\BitArticleType; // Is package installed and enabled $gBitSystem->verifyPackage( 'articles' ); @@ -11,60 +12,60 @@ $gBitSystem->verifyPackage( 'articles' ); // Now check permissions to access this page $gBitSystem->verifyPermission( 'p_articles_admin' ); -$artTypes = array( - 'use_ratings' => array( - 'name' => tra( 'Rate' ), - 'desc' => tra( 'Allow ratings by the author' ), - ), - 'show_pre_publ' => array( - 'name' => tra( 'Show before publish date' ), - 'desc' => tra( 'non-admins can view before the publish date' ), - ), - 'show_post_expire' => array( - 'name' => tra( 'Show after expire date' ), - 'desc' => tra( 'non-admins can view after the expire date' ), - ), - 'heading_only' => array( - 'name' => tra( 'Heading only' ), - 'desc' => tra( 'No article body, heading only' ), - ), - 'allow_comments' => array( - 'name' => tra( 'Comments' ), - 'desc' => tra( 'Allow comments for this type' ), - ), - 'show_image' => array( - 'name' => tra( 'Show image' ), - 'desc' => tra( 'Show topic or image' ), - ), - 'show_avatar' => array( - 'name' => tra( 'Show avatar' ), - 'desc' => tra( 'Show author\'s avatar' ), - ), - 'show_author' => array( - 'name' => tra( 'Show author' ), - 'desc' => tra( 'Show author\'s name' ), - ), - 'show_pubdate' => array( - 'name' => tra( 'Show publish date' ), - 'desc' => tra( 'Show publication date' ), - ), - 'show_expdate' => array( - 'name' => tra( 'Show expiration date' ), - 'desc' => tra( 'Show expiration date' ), - ), - 'show_reads' => array( - 'name' => tra( 'Show reads' ), - 'desc' => tra( 'Show the number of times an article has been read' ), - ), - 'show_size' => array( - 'name' => tra( 'Show size' ), - 'desc' => tra( 'Show the size of the article' ), - ), - 'creator_edit' => array( - 'name' => tra( 'Creator can edit' ), - 'desc' => tra( 'The person who submits an article of this type can edit it' ), +$artTypes = [ + 'use_ratings' => [ + 'name' => KernelTools::tra( 'Rate' ), + 'desc' => KernelTools::tra( 'Allow ratings by the author' ), + ], + 'show_pre_publ' => [ + 'name' => KernelTools::tra( 'Show before publish date' ), + 'desc' => KernelTools::tra( 'non-admins can view before the publish date' ), + ], + 'show_post_expire' => [ + 'name' => KernelTools::tra( 'Show after expire date' ), + 'desc' => KernelTools::tra( 'non-admins can view after the expire date' ), + ], + 'heading_only' => [ + 'name' => KernelTools::tra( 'Heading only' ), + 'desc' => KernelTools::tra( 'No article body, heading only' ), + ], + 'allow_comments' => [ + 'name' => KernelTools::tra( 'Comments' ), + 'desc' => KernelTools::tra( 'Allow comments for this type' ), + ], + 'show_image' => [ + 'name' => KernelTools::tra( 'Show image' ), + 'desc' => KernelTools::tra( 'Show topic or image' ), + ], + 'show_avatar' => [ + 'name' => KernelTools::tra( 'Show avatar' ), + 'desc' => KernelTools::tra( 'Show author\'s avatar' ), + ], + 'show_author' => array( + 'name' => KernelTools::tra( 'Show author' ), + 'desc' => KernelTools::tra( 'Show author\'s name' ), ), -); + 'show_pubdate' => [ + 'name' => KernelTools::tra( 'Show publish date' ), + 'desc' => KernelTools::tra( 'Show publication date' ), + ], + 'show_expdate' => [ + 'name' => KernelTools::tra( 'Show expiration date' ), + 'desc' => KernelTools::tra( 'Show expiration date' ), + ], + 'show_reads' => [ + 'name' => KernelTools::tra( 'Show reads' ), + 'desc' => KernelTools::tra( 'Show the number of times an article has been read' ), + ], + 'show_size' => [ + 'name' => KernelTools::tra( 'Show size' ), + 'desc' => KernelTools::tra( 'Show the size of the article' ), + ], + 'creator_edit' => [ + 'name' => KernelTools::tra( 'Creator can edit' ), + 'desc' => KernelTools::tra( 'The person who submits an article of this type can edit it' ), + ], +]; $gBitSmarty->assign( 'artTypes', $artTypes ); $gContent = new BitArticleType( !empty( $_REQUEST['article_type_id'] ) ? $_REQUEST['article_type_id'] : NULL ); @@ -88,4 +89,4 @@ $types = BitArticleType::getTypeList(); $gBitSmarty->assign( 'types', $types ); // Display the template -$gBitSystem->display( 'bitpackage:articles/admin_types.tpl', tra('Edit Article Types') , array( 'display_mode' => 'admin' )); +$gBitSystem->display( 'bitpackage:articles/admin_types.tpl', KernelTools::tra('Edit Article Types') , [ 'display_mode' => 'admin' ]); diff --git a/admin/index.php b/admin/index.php index 30a5490..30a5490 100644..100755 --- a/admin/index.php +++ b/admin/index.php diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 09b7cd3..6f40c0e 100644..100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -5,13 +5,13 @@ // removed size, topic_name (replaced with topic_id) // replaced type_name with article_type_id -$tables = array( +$tables = [ 'article_status' => " status_id I4 PRIMARY, status_name C(64) ", - 'article_types' => " + 'article_types' => " article_type_id I4 PRIMARY, type_name C(50), use_ratings C(1), @@ -38,7 +38,7 @@ $tables = array( created I8 ", - 'articles' => " + 'articles' => " article_id I4 PRIMARY, content_id I4 NOTNULL, description X, @@ -49,12 +49,12 @@ $tables = array( topic_id I4, rating F, status_id I4 - CONSTRAINT ', CONSTRAINT `articles_content_ref` FOREIGN KEY (`content_id`) REFERENCES `".BIT_DB_PREFIX."liberty_content` (`content_id`) - , CONSTRAINT `articles_topic_ref` FOREIGN KEY (`topic_id`) REFERENCES `".BIT_DB_PREFIX."article_topics` (`topic_id`) - , CONSTRAINT `articles_type_ref` FOREIGN KEY (`article_type_id`) REFERENCES `".BIT_DB_PREFIX."article_types` (`article_type_id`) - , CONSTRAINT `articles_status` FOREIGN KEY (`status_id`) REFERENCES `".BIT_DB_PREFIX."article_status` (`status_id`)' + CONSTRAINT ', CONSTRAINT `articles_content_ref` FOREIGN KEY (`content_id`) REFERENCES `" . BIT_DB_PREFIX . "liberty_content` (`content_id`) + , CONSTRAINT `articles_topic_ref` FOREIGN KEY (`topic_id`) REFERENCES `" . BIT_DB_PREFIX . "article_topics` (`topic_id`) + , CONSTRAINT `articles_type_ref` FOREIGN KEY (`article_type_id`) REFERENCES `" . BIT_DB_PREFIX . "article_types` (`article_type_id`) + , CONSTRAINT `articles_status` FOREIGN KEY (`status_id`) REFERENCES `" . BIT_DB_PREFIX . "article_status` (`status_id`)' ", -); +]; global $gBitInstaller; @@ -80,65 +80,65 @@ $gBitInstaller->registerSchemaSequences( ARTICLES_PKG_NAME, $sequences ); // $indices = array(); // $gBitInstaller->registerSchemaIndexes( ARTICLES_PKG_NAME, $indices ); -$gBitInstaller->registerSchemaDefault( ARTICLES_PKG_NAME, array( - "INSERT INTO `".BIT_DB_PREFIX."article_types` (`article_type_id`, `type_name`) VALUES (1, 'Article')", - "INSERT INTO `".BIT_DB_PREFIX."article_types` (`article_type_id`, `type_name`, `use_ratings`) VALUES (2, 'Review','y')", - "INSERT INTO `".BIT_DB_PREFIX."article_types` (`article_type_id`, `type_name`, `show_post_expire`) VALUES (3, 'Event','n')", - "INSERT INTO `".BIT_DB_PREFIX."article_types` (`article_type_id`, `type_name`, `show_post_expire`,`heading_only`,`allow_comments`) VALUES (4, 'Classified','n','y','n')", - "INSERT INTO `".BIT_DB_PREFIX."article_status` (`status_id`, `status_name`) VALUES ( 0, 'Denied') ", - "INSERT INTO `".BIT_DB_PREFIX."article_status` (`status_id`, `status_name`) VALUES (100, 'Draft') ", - "INSERT INTO `".BIT_DB_PREFIX."article_status` (`status_id`, `status_name`) VALUES (200, 'Pending Approval') ", - "INSERT INTO `".BIT_DB_PREFIX."article_status` (`status_id`, `status_name`) VALUES (300, 'Approved') ", - "INSERT INTO `".BIT_DB_PREFIX."article_status` (`status_id`, `status_name`) VALUES (400, 'Retired') " -) ); +$gBitInstaller->registerSchemaDefault( ARTICLES_PKG_NAME, [ + "INSERT INTO `" . BIT_DB_PREFIX . "article_types` (`article_type_id`, `type_name`) VALUES (1, 'Article')", + "INSERT INTO `" . BIT_DB_PREFIX . "article_types` (`article_type_id`, `type_name`, `use_ratings`) VALUES (2, 'Review','y')", + "INSERT INTO `" . BIT_DB_PREFIX . "article_types` (`article_type_id`, `type_name`, `show_post_expire`) VALUES (3, 'Event','n')", + "INSERT INTO `" . BIT_DB_PREFIX . "article_types` (`article_type_id`, `type_name`, `show_post_expire`,`heading_only`,`allow_comments`) VALUES (4, 'Classified','n','y','n')", + "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES ( 0, 'Denied') ", + "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (100, 'Draft') ", + "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (200, 'Pending Approval') ", + "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (300, 'Approved') ", + "INSERT INTO `" . BIT_DB_PREFIX . "article_status` (`status_id`, `status_name`) VALUES (400, 'Retired') " +] ); // ### Default UserPermissions -$gBitInstaller->registerUserPermissions( ARTICLES_PKG_NAME, array( - array('p_articles_update', 'Can update articles', 'editors', ARTICLES_PKG_NAME), - array('p_articles_remove', 'Can remove articles', 'editors', ARTICLES_PKG_NAME), - array('p_articles_read', 'Can read articles', 'basic', ARTICLES_PKG_NAME), - array('p_articles_read_history', 'Can read article history', 'registered', ARTICLES_PKG_NAME), - array('p_articles_submit', 'Can submit articles', 'basic', ARTICLES_PKG_NAME), - array('p_articles_update_submission', 'Can update submissions', 'editors', ARTICLES_PKG_NAME), - array('p_articles_remove_submission', 'Can remove submissions', 'editors', ARTICLES_PKG_NAME), - array('p_articles_approve_submission', 'Can approve submissions', 'editors', ARTICLES_PKG_NAME), - array('p_articles_send', 'Can send articles to other sites', 'editors', ARTICLES_PKG_NAME), - array('p_articles_sendme', 'Can send articles to this site', 'registered', ARTICLES_PKG_NAME), - array('p_articles_auto_approve', 'Submited articles automatically approved', 'editors', ARTICLES_PKG_NAME), - array('p_articles_admin', 'Can admin the articles package', 'editors', ARTICLES_PKG_NAME), -) ); +$gBitInstaller->registerUserPermissions( ARTICLES_PKG_NAME, [ + [ 'p_articles_update', 'Can update articles', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_remove', 'Can remove articles', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_read', 'Can read articles', 'basic', ARTICLES_PKG_NAME ], + [ 'p_articles_read_history', 'Can read article history', 'registered', ARTICLES_PKG_NAME ], + [ 'p_articles_submit', 'Can submit articles', 'basic', ARTICLES_PKG_NAME ], + [ 'p_articles_update_submission', 'Can update submissions', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_remove_submission', 'Can remove submissions', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_approve_submission', 'Can approve submissions', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_send', 'Can send articles to other sites', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_sendme', 'Can send articles to this site', 'registered', ARTICLES_PKG_NAME ], + [ 'p_articles_auto_approve', 'Submited articles automatically approved', 'editors', ARTICLES_PKG_NAME ], + [ 'p_articles_admin', 'Can admin the articles package', 'editors', ARTICLES_PKG_NAME ], +] ); // ### Default Preferences -$gBitInstaller->registerPreferences( ARTICLES_PKG_NAME, array( - array( ARTICLES_PKG_NAME, 'articles_attachments','y'), - array( ARTICLES_PKG_NAME, 'articles_list_author','y'), - array( ARTICLES_PKG_NAME, 'articles_list_date','y'), - array( ARTICLES_PKG_NAME, 'articles_list_img','y'), - array( ARTICLES_PKG_NAME, 'articles_list_reads','y'), - array( ARTICLES_PKG_NAME, 'articles_list_size','y'), - array( ARTICLES_PKG_NAME, 'articles_list_title','y'), - array( ARTICLES_PKG_NAME, 'articles_list_topic','y'), - array( ARTICLES_PKG_NAME, 'articles_list_type','y'), - array( ARTICLES_PKG_NAME, 'articles_list_expire','y'), - array( ARTICLES_PKG_NAME, 'articles_max_list','10'), - array( ARTICLES_PKG_NAME, 'articles_rankings','y'), - array( ARTICLES_PKG_NAME, 'articles_submissions', 'y'), - array( ARTICLES_PKG_NAME, 'articles_description_length', '500'), - array( ARTICLES_PKG_NAME, 'articles_date_threshold', 'week'), -) ); +$gBitInstaller->registerPreferences( ARTICLES_PKG_NAME, [ + [ ARTICLES_PKG_NAME, 'articles_attachments', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_author', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_date', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_img', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_reads', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_size', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_title', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_topic', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_type', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_list_expire', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_max_list', '10' ], + [ ARTICLES_PKG_NAME, 'articles_rankings', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_submissions', 'y' ], + [ ARTICLES_PKG_NAME, 'articles_description_length', '500' ], + [ ARTICLES_PKG_NAME, 'articles_date_threshold', 'week' ], +] ); if( defined( 'RSS_PKG_NAME' )) { $gBitInstaller->registerPreferences( ARTICLES_PKG_NAME, array( - array( RSS_PKG_NAME, ARTICLES_PKG_NAME.'_rss', 'y'), + [ RSS_PKG_NAME, ARTICLES_PKG_NAME . '_rss', 'y' ], )); } // ### Register content types -$gBitInstaller->registerContentObjects( ARTICLES_PKG_NAME, array( - 'BitArticle'=>ARTICLES_PKG_CLASS_PATH.'BitArticle.php', -)); +$gBitInstaller->registerContentObjects( ARTICLES_PKG_NAME, [ + 'BitArticle' => ARTICLES_PKG_CLASS_PATH . 'BitArticle.php', +]); // Requirements -$gBitInstaller->registerRequirements( ARTICLES_PKG_NAME, array( - 'liberty' => array( 'min' => '2.1.4' ), -)); +$gBitInstaller->registerRequirements( ARTICLES_PKG_NAME, [ + 'liberty' => [ 'min' => '5.0.0' ], +]); diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php deleted file mode 100644 index 6434a77..0000000 --- a/admin/upgrade_inc.php +++ /dev/null @@ -1,393 +0,0 @@ -<?php - -global $gBitSystem, $gUpgradeFrom, $gUpgradeTo; -require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' ); - -if( !defined( 'BITARTICLE_CONTENT_TYPE_GUID' ) ) { - define( 'BITARTICLE_CONTENT_TYPE_GUID', 'bitarticle' ); -} - -$upgrades = array( - - 'BWR1' => array( - 'BWR2' => array( - -// de-tikify tables -array( 'DATADICT' => array( - array( 'RENAMETABLE' => array( - 'tiki_articles' => 'articles', - 'tiki_article_status' => 'article_status', - 'tiki_article_types' => 'article_types', - 'tiki_article_topics' => 'article_topics', - )), - array( 'RENAMESEQUENCE' => array( - "tiki_article_topics_topic_id_seq" => "articles_topics_id_seq", - "tiki_article_types_article_type_id_seq" => "article_types_a_t_id_seq", - "tiki_articles_article_id_seq" => "articles_article_id_seq", - )), - array( 'RENAMECOLUMN' => array( - 'article_topics' => array( - '`active`' => '`active_topic` C(1)' - ), - )), -)), - -// we will try to convert article images to attachments -array( 'PHP' => ' - global $gBitSystem, $gBitUser; - require_once( LIBERTY_PKG_CLASS_PATH.'LibertyAttachable.php' ); - - $query = " - SELECT - a.`article_id`, - a.`content_id`, - c.`user_id` - FROM `'.BIT_DB_PREFIX.'articles` a - INNER JOIN `'.BIT_DB_PREFIX.'liberty_content` c ON( a.`content_id` = c.`content_id` ) - "; - - if( $articles = $gBitSystem->mDb->getAll( $query ) ) { - foreach( $articles as $article ) { - // store article image - $image_name = "article_".$article["article_id"].".jpg"; - // debug: vd($image_name); vd($article); - if( is_file( STORAGE_PKG_PATH.ARTICLES_PKG_NAME."/".$image_name )) { - $storeRow["plugin_guid"] = "bitfile"; - $storeRow["user_id"] = $article["user_id"]; - $storeRow["content_id"] = $article["content_id"]; - $storeRow["attachment_id"] = $gBitSystem->mDb->GenID( "liberty_attachments_id_seq" ); - $storeRow["foreign_id"] = $gBitSystem->mDb->GenID( "liberty_files_id_seq" ); - $storeRow["user_id"] = !empty( $article["user_id"] ) ? $article["user_id"] : $gBitUser->mUserId; - $storeRow["upload"]["source_file"] = STORAGE_PKG_PATH.ARTICLES_PKG_NAME."/".$image_name; - $storeRow["upload"]["attachment_id"] = $storeRow["attachment_id"]; - $storeRow["upload"]["name"] = $image_name; - $storeRow["upload"]["type"] = "image/jpeg"; - $storeRow["upload"]["size"] = filesize( $storeRow["upload"]["source_file"] ); - $storeRow["upload"]["dest_path"] = LibertyAttachable::getStorageBranch( $storeRow["attachment_id"], $storeRow["user_id"], LibertyAttachable::getStorageSubDirName() ); - - $sql = "INSERT INTO `'.BIT_DB_PREFIX.'liberty_files` ( `storage_path`, `file_id`, `mime_type`, `file_size`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )"; - $gBitSystem->mDb->query( $sql, array( - $storeRow["upload"]["dest_path"].$storeRow["upload"]["name"], - $storeRow["foreign_id"], - $storeRow["upload"]["type"], - $storeRow["upload"]["size"], - $storeRow["user_id"], - )); - - $storeRow["upload"]["dest_file_path"] = liberty_process_upload( $storeRow[\'upload\'] ); - - $sql = "INSERT INTO `'.BIT_DB_PREFIX.'liberty_attachments` ( `content_id`, `attachment_id`, `attachment_plugin_guid`, `foreign_id`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )"; - $rs = $gBitSystem->mDb->query( $sql, array( $storeRow["content_id"], $storeRow["attachment_id"], $storeRow["plugin_guid"], (int)$storeRow["foreign_id"], $storeRow["user_id"] ) ); - - @unlink( $tmpImagePath ); - unset( $storeHash ); - } - } - } -'), - - ) - ), // end BWR1 --> BWR2 - - 'TIKIWIKI19' => array ( - 'TIKIWIKI18' => array ( - -array( 'DATADICT' => array( - array( 'DROPCOLUMN' => array( - 'tiki_submissions' => array( '`bibliographical_references`' ), - )), -)), - -/* Sliced and diced TW 1.9 upgrade scripts that did actual schema alterations - -ALTER TABLE `tiki_articles` ADD `topline` VARCHAR( 255 ) AFTER `articleId` ; -ALTER TABLE `tiki_articles` ADD `subtitle` VARCHAR( 255 ) AFTER `title` ; -ALTER TABLE `tiki_articles` ADD `linkto` VARCHAR( 255 ) AFTER `subtitle` ; -ALTER TABLE `tiki_articles` ADD `image_caption` TEXT AFTER `image_name` ; -ALTER TABLE `tiki_submissions` ADD `topline` VARCHAR( 255 ) AFTER `subId` ; -ALTER TABLE `tiki_submissions` ADD `subtitle` VARCHAR( 255 ) AFTER `title` ; -ALTER TABLE `tiki_submissions` ADD `linkto` VARCHAR( 255 ) AFTER `subtitle` ; -ALTER TABLE `tiki_submissions` ADD `image_caption` TEXT AFTER `image_name` ; -ALTER TABLE `tiki_articles` ADD `lang` VARCHAR( 16 ) AFTER `linkto` ; -ALTER TABLE `tiki_submissions` ADD `lang` VARCHAR( 16 ) AFTER `linkto` ; -ALTER TABLE `tiki_article_types` ADD `show_topline` CHAR( 1 ) AFTER `show_size` ; -ALTER TABLE `tiki_article_types` ADD `show_subtitle` CHAR( 1 ) AFTER `show_topline` ; -ALTER TABLE `tiki_article_types` ADD `show_linkto` CHAR( 1 ) AFTER `show_subtitle` ; -ALTER TABLE `tiki_article_types` ADD `show_image_caption` CHAR( 1 ) AFTER `show_linkto` ; -ALTER TABLE `tiki_article_types` ADD `show_lang` CHAR( 1 ) AFTER `show_image_caption` ; - -*/ - ) - ), - - - 'BONNIE' => array( - 'BWR1' => array( - -// STEP 0 -array( 'QUERY' => - array( 'MYSQL' => array( - "ALTER TABLE `".BIT_DB_PREFIX."tiki_articles` DROP PRIMARY KEY", - "ALTER TABLE `".BIT_DB_PREFIX."tiki_article_types` DROP PRIMARY KEY", - "ALTER TABLE `".BIT_DB_PREFIX."tiki_topics` DROP PRIMARY KEY", - )), -), - -// STEP 1 -array( 'DATADICT' => array( - // RENAME - array( 'RENAMETABLE' => array( - 'tiki_topics' => 'tiki_article_topics', - )), - array( 'RENAMECOLUMN' => array( - 'tiki_articles' => array( - '`articleId`' => '`article_id` I4', - '`authorName`' => '`author_name` C(250)', - '`publishDate`' => '`publish_date` I4', - '`expireDate`' => '`expire_date` I4', - '`topicId`' => '`topic_id` I4', - '`rating`' => '`rating` F', - ), - 'tiki_article_types' => array( - '`type`' => '`type_name` C(50)', - ), - 'tiki_article_topics' => array( - '`topicId`' => '`topic_id` I4', - '`name`' => '`topic_name` C(40)', - ), - )), - // ALTER - array( 'ALTER' => array( - 'tiki_articles' => array( - 'content_id' => array( '`content_id`', 'I4' ), - 'description' => array( '`description`', 'X' ), - 'status_id' => array( '`status_id`', 'I4' ), - 'article_type_id' => array( '`article_type_id`', 'I4' ), - ), - 'tiki_article_types' => array( - 'article_type_id' => array( '`article_type_id`', 'I4' ), - ), - 'tiki_article_topics' => array( - 'has_topic_image' => array( '`has_topic_image`', 'VARCHAR(1)' ), - ), - )), - // CREATE - array( 'CREATE' => array ( - 'tiki_article_status' => " - status_id I4 PRIMARY, - status_name C(64) - ", - )), -)), - -// STEP 3 -array( 'PHP' => ' - global $gBitSystem; - // this define is needed for backwards compatability. - define( "ARTICLE_TOPIC_THUMBNAIL_SIZE", 160 ); - require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' ); - - // BitArticle has 3 sequences, each needs creating prior to execution - $max_articles = $gBitSystem->mDb->getOne( "SELECT MAX(`article_id`) FROM `'.BIT_DB_PREFIX.'tiki_articles`" ); - $gBitSystem->mDb->CreateSequence( "tiki_articles_article_id_seq", $max_articles + 1 ); - $max_topics = $gBitSystem->mDb->getOne( "SELECT MAX(`topic_id`) FROM `'.BIT_DB_PREFIX.'tiki_article_topics`" ); - $gBitSystem->mDb->CreateSequence( "tiki_article_topics_topic_id_seq", $max_topics + 1 ); - $max_types = $gBitSystem->mDb->getOne( "SELECT MAX(`article_type_id`) FROM `'.BIT_DB_PREFIX.'tiki_article_types`" ); - $gBitSystem->mDb->CreateSequence( "tiki_article_types_article_type_id_seq", $max_types + 1 ); - - // tiki_articles - $query = " - SELECT - ta.`article_id`, - ta.`created` AS `created`, - ta.`created` AS `last_modified`, - ta.`heading`, - ta.`body`, - ta.`title`, - ta.`reads` AS `hits` - FROM `'.BIT_DB_PREFIX.'tiki_articles` ta"; - - if( $rs = $gBitSystem->mDb->query( $query ) ) { - while( !$rs->EOF ) { - $artId = $rs->fields["article_id"]; - unset( $rs->fields["article_id"] ); - $conId = $gBitSystem->mDb->GenID( "tiki_content_id_seq" ); - if( !empty( $rs->fields["heading"] ) && !empty( $rs->fields["heading"] ) ) { - $rs->fields["data"] = $rs->fields["heading"]."...split...\n".$rs->fields["body"]; - } else { - $rs->fields["data"] = $rs->fields["heading"]; - } - unset( $rs->fields["body"] ); - unset( $rs->fields["heading"] ); - $rs->fields["content_id"] = $conId; - $rs->fields["content_type_guid"] = BITARTICLE_CONTENT_TYPE_GUID; - $rs->fields["format_guid"] = PLUGIN_GUID_TIKIWIKI; - $gBitSystem->mDb->associateInsert( "tiki_content", $rs->fields ); - $gBitSystem->mDb->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_articles` SET `content_id`=? WHERE `article_id`=?", array( $conId, $artId ) ); - $rs->MoveNext(); - } - } - - // article images and state - // work out what resizer to use - $resizeFunc = ( $gBitSystem->getConfig( "image_processor" ) == "imagick" ) ? "liberty_imagick_resize_image" : "liberty_gd_resize_image"; - // make sure we have a place to store the images - $tempDir = TEMP_PKG_PATH.ARTICLES_PKG_NAME; - $storageDir = STORAGE_PKG_PATH.ARTICLES_PKG_NAME; - if( !is_dir( $tempDir ) || !is_dir( $storageDir ) ) { - mkdir_p( $tempDir ); - mkdir_p( $storageDir ); - } - - $query = " - SELECT - ta.`state`, - ta.`article_id`, - ta.`image_name`, - ta.`image_type`, - ta.`image_data` - FROM `'.BIT_DB_PREFIX.'tiki_articles` ta"; - - if( $rs = $gBitSystem->mDb->query( $query ) ) { - while( !$rs->EOF ) { - // store article image - if( !empty( $rs->fields["image_name"] ) ) { - $tmpImagePath = $tempDir.$rs->fields["image_name"]; - if( $handle = fopen( $tmpImagePath, "a" ) ) { - fwrite( $handle, $rs->fields["image_data"] ); - fclose( $handle ); - } else { - $gBitInstaller->mErrors["upgrade"][ARTICLES_PKG_NAME]["article_image_create"][] = "Error while creating article image: ".$rs->fields["image_name"]; - } - $storeHash["source_file"] = $tmpImagePath; - $storeHash["dest_path"] = STORAGE_PKG_URL.ARTICLES_PKG_NAME."/"; - $storeHash["dest_base_name"] = "article_".$rs->fields["article_id"]; - $storeHash["max_width"] = ARTICLE_TOPIC_THUMBNAIL_SIZE; - $storeHash["max_height"] = ARTICLE_TOPIC_THUMBNAIL_SIZE; - $storeHash["type"] = $rs->fields["image_type"]; - - if( $resizeFunc( $storeHash ) ) { - $gBitInstaller->mErrors["upgrade"][ARTICLES_PKG_NAME]["article_image_resize"][] = "Error while resizing article image: ".$rs->fields["image_name"]; - } - - @unlink( $tmpImagePath ); - unset( $storeHash ); - } - - if( $rs->fields["state"] == "p" ) { - $gBitSystem->mDb->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_articles` SET `status_id`=? WHERE `article_id`=?", array( 400, $rs->fields["article_id"] ) ); - } elseif( $rs->fields["state"] == "s" ) { - $gBitSystem->mDb->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_articles` SET `status_id`=? WHERE `article_id`=?", array( 300, $rs->fields["article_id"] ) ); - } - - $rs->MoveNext(); - } - } - - // tiki_article_topics - $query = " - SELECT - ta.`topic_id`, - ta.`image_name`, - ta.`image_type`, - ta.`image_data` - FROM `'.BIT_DB_PREFIX.'tiki_article_topics` ta"; - - if( $rs = $gBitSystem->mDb->query( $query ) ) { - while( !$rs->EOF ) { - // store topic image - if( !empty( $rs->fields["image_name"] ) ) { - $tmpImagePath = $tempDir.$rs->fields["image_name"]; - if( $handle = fopen( $tmpImagePath, "a" ) ) { - fwrite( $handle, $rs->fields["image_data"] ); - fclose( $handle ); - } else { - $gBitInstaller->mErrors["upgrade"][ARTICLES_PKG_NAME]["topic_image_create"][] = "Error while creating topic image: ".$rs->fields["image_name"]; - } - - $storeHash["source_file"] = $tmpImagePath; - $storeHash["dest_path"] = STORAGE_PKG_URL.ARTICLES_PKG_NAME."/"; - $storeHash["dest_base_name"] = "topic_".$rs->fields["topic_id"]; - $storeHash["max_width"] = ARTICLE_TOPIC_THUMBNAIL_SIZE; - $storeHash["max_height"] = ARTICLE_TOPIC_THUMBNAIL_SIZE; - $storeHash["type"] = $rs->fields["image_type"]; - - if( $resizeFunc( $storeHash ) ) { - $gBitInstaller->mErrors["upgrade"][ARTICLES_PKG_NAME]["topic_image_resize"][] = "Error while resizing topic image: ".$rs->fields["image_name"]; - } - - $gBitSystem->mDb->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_article_topics` SET `has_topic_image`=? WHERE `topic_id`=?", array( "y", $rs->fields["topic_id"] ) ); - @unlink( $tmpImagePath ); - unset( $storeHash ); - } else { - $gBitSystem->mDb->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_article_topics` SET `has_topic_image`=? WHERE `topic_id`=?", array( "n", $rs->fields["topic_id"] ) ); - } - $rs->MoveNext(); - } - } - - // tiki_article_types - // might be cumbersome, but i dont kow how else to do this - $query = "SELECT * FROM `'.BIT_DB_PREFIX.'tiki_article_types`"; - - if( $rs = $gBitSystem->mDb->query( $query ) ) { - $typeId = 1; - while( !$rs->EOF ) { - $gBitSystem->mDb->query( "UPDATE `'.BIT_DB_PREFIX.'tiki_article_types` SET `article_type_id`=? WHERE `type_name`=?", array( $typeId, $rs->fields["type_name"] ) ); - $typeId++; - $rs->MoveNext(); - } - } -'), - -// STEP 4 -array( 'QUERY' => - array( 'SQL92' => array( - "UPDATE `".BIT_DB_PREFIX."tiki_articles` SET `article_type_id`=( SELECT types.`article_type_id` FROM `".BIT_DB_PREFIX."tiki_article_types` types WHERE types.`type_name`=`".BIT_DB_PREFIX."tiki_articles`.`type` )", - - // update comments for articles - "UPDATE `".BIT_DB_PREFIX."tiki_comments` SET `objectType`='".BITARTICLE_CONTENT_TYPE_GUID."' WHERE `objectType`='articles'", - - // insert default values for status table - "INSERT INTO `".BIT_DB_PREFIX."tiki_article_status`( `status_id`, `status_name` ) VALUES( 0, 'Denied' )", - "INSERT INTO `".BIT_DB_PREFIX."tiki_article_status`( `status_id`, `status_name` ) VALUES( 100, 'Draft' )", - "INSERT INTO `".BIT_DB_PREFIX."tiki_article_status`( `status_id`, `status_name` ) VALUES( 200, 'Pending Approval' )", - "INSERT INTO `".BIT_DB_PREFIX."tiki_article_status`( `status_id`, `status_name` ) VALUES( 300, 'Approved' )", - "INSERT INTO `".BIT_DB_PREFIX."tiki_article_status`( `status_id`, `status_name` ) VALUES( 400, 'Retired' )", - - // some default preferences - "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences`( `name`, `value`, `package` ) VALUES( 'article_description_length', '500', '".ARTICLES_PKG_NAME."' )", - "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences`( `name`, `value`, `package` ) VALUES( 'max_articles', '10', '".ARTICLES_PKG_NAME."' )", - - // add in permissions not in TW 1.8 - may get failures on some duplicates - "INSERT INTO `".BIT_DB_PREFIX."users_permissions`( `perm_name`,`perm_desc`, `level`, `package` ) VALUES( 'bit_p_admin_articles', 'Can admin the articles package', 'editors', 'articles' )", - )), -), - -// STEP 5 -array( 'PHP' => '' ), - -// STEP 6 -array( 'DATADICT' => array( - array( 'DROPCOLUMN' => array( - 'tiki_articles' => array( '`title`', '`state`', '`topicName`', '`size`', '`useImage`', '`image_name`', '`image_size`', '`image_type`', '`image_x`', '`image_y`', '`image_data`', '`created`', '`heading`', '`body`', '`hash`', '`author`', '`reads`', '`votes`', '`points`', '`type`', '`isfloat`' ), - 'tiki_article_topics' => array( '`image_name`', '`image_type`', '`image_size`', '`image_data`' ), - )), -)), - -/* -// STEP 7 -array( 'DATADICT' => array( - array( 'CREATEINDEX' => array( - 'tiki_articles_articles_idx' => array( 'tiki_articles', '`article_id`', array() ), - )), -)), -*/ - - ), - ), -); - -if ( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) { - $gBitSystem->registerUpgrade( ARTICLES_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] ); -} diff --git a/admin/upgrades/1.0.0.php b/admin/upgrades/1.0.0.php deleted file mode 100644 index a3277e5..0000000 --- a/admin/upgrades/1.0.0.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * @version $Header$ - */ -global $gBitInstaller; - -$infoHash = array( - 'package' => ARTICLES_PKG_NAME, - 'version' => str_replace( '.php', '', basename( __FILE__ )), - 'description' => "Fix the names of sequence tables to be standardized.", - 'post_upgrade' => NULL, -); - -$gBitInstaller->registerPackageUpgrade( $infoHash, array( - array( 'DATADICT' => array( - array( 'RENAMESEQUENCE' => array( - "article_types_a_t_id_seq" => "article_types_id_seq", - "articles_topics_id_seq" => "article_topics_id_seq", - )), - array( 'DROPSEQUENCE' => array( 'article_topics_t_id_seq' ) ), - )), -)); |
