summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-02-01 17:57:53 +0000
committerlsces <lester@lsces.co.uk>2026-02-01 17:57:53 +0000
commit0b7bc39d45c39f36e13e704ac126f9246a9be62f (patch)
treebed4210bdc7e2c43716ca3d42a44e9cbbc58780d
parente75480ed0929f12c69465d63aba1615db7b9436a (diff)
downloadarticles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.tar.gz
articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.tar.bz2
articles-0b7bc39d45c39f36e13e704ac126f9246a9be62f.zip
Major refactor for namespace, php8.4 and smarty5
-rwxr-xr-x[-rw-r--r--].hgtags0
-rwxr-xr-x[-rw-r--r--].htaccess0
-rwxr-xr-x[-rw-r--r--]admin/admin_articles_inc.php140
-rwxr-xr-x[-rw-r--r--]admin/admin_topics.php8
-rwxr-xr-x[-rw-r--r--]admin/admin_types.php113
-rwxr-xr-x[-rw-r--r--]admin/index.php0
-rwxr-xr-x[-rw-r--r--]admin/schema_inc.php114
-rw-r--r--admin/upgrade_inc.php393
-rw-r--r--admin/upgrades/1.0.0.php22
-rwxr-xr-x[-rw-r--r--]article_history.php15
-rwxr-xr-x[-rw-r--r--]articles_rss.php3
-rw-r--r--bit_setup_inc.php28
-rwxr-xr-x[-rw-r--r--]edit.php2
-rwxr-xr-x[-rw-r--r--]edit_topic.php2
-rwxr-xr-x[-rw-r--r--]icons/pkg_articles.gifbin1599 -> 1599 bytes
-rwxr-xr-x[-rw-r--r--]icons/pkg_articles.pngbin2147 -> 2147 bytes
-rwxr-xr-x[-rw-r--r--]icons/rating.gifbin355 -> 355 bytes
-rwxr-xr-x[-rw-r--r--]icons/rating.pngbin587 -> 587 bytes
-rwxr-xr-x[-rw-r--r--]icons/rating_off.gifbin355 -> 355 bytes
-rwxr-xr-x[-rw-r--r--]icons/rating_off.pngbin522 -> 522 bytes
-rwxr-xr-x[-rw-r--r--]includes/article_filter_inc.php3
-rwxr-xr-xincludes/bit_setup_inc.php43
-rwxr-xr-x[-rw-r--r--]includes/classes/BitArticle.php167
-rwxr-xr-x[-rw-r--r--]includes/classes/BitArticleTopic.php261
-rwxr-xr-x[-rw-r--r--]includes/classes/BitArticleType.php34
-rwxr-xr-x[-rw-r--r--]includes/display_article_inc.php11
-rwxr-xr-x[-rw-r--r--]includes/lookup_article_inc.php3
-rwxr-xr-x[-rw-r--r--]includes/lookup_article_topic_inc.php11
-rwxr-xr-x[-rw-r--r--]index.php18
-rwxr-xr-x[-rw-r--r--]liberty_plugins/data.articles.php66
-rwxr-xr-x[-rw-r--r--]list.php18
-rwxr-xr-x[-rw-r--r--]list_topics.php6
-rwxr-xr-x[-rw-r--r--]modules/help_mod_articles.tpl0
-rwxr-xr-x[-rw-r--r--]modules/index.php0
-rwxr-xr-x[-rw-r--r--]modules/mod_articles.php31
-rwxr-xr-x[-rw-r--r--]modules/mod_articles.tpl0
-rwxr-xr-x[-rw-r--r--]print.php8
-rwxr-xr-x[-rw-r--r--]rankings.php45
-rwxr-xr-x[-rw-r--r--]read.php18
-rwxr-xr-x[-rw-r--r--]templates/admin_articles.tpl0
-rwxr-xr-x[-rw-r--r--]templates/admin_topics.tpl0
-rwxr-xr-x[-rw-r--r--]templates/admin_types.tpl0
-rwxr-xr-x[-rw-r--r--]templates/article_display.tpl0
-rwxr-xr-x[-rw-r--r--]templates/article_filter_inc.tpl0
-rwxr-xr-x[-rw-r--r--]templates/article_history.tpl0
-rwxr-xr-x[-rw-r--r--]templates/articles_mini_search.tpl0
-rwxr-xr-x[-rw-r--r--]templates/articles_nav.tpl0
-rwxr-xr-x[-rw-r--r--]templates/center_display_articles.php28
-rwxr-xr-x[-rw-r--r--]templates/center_display_articles.tpl0
-rwxr-xr-x[-rw-r--r--]templates/center_list_articles.php27
-rwxr-xr-x[-rw-r--r--]templates/center_list_articles.tpl0
-rwxr-xr-x[-rw-r--r--]templates/edit_article.tpl2
-rwxr-xr-x[-rw-r--r--]templates/edit_topic.tpl0
-rwxr-xr-x[-rw-r--r--]templates/html_head_inc.tpl0
-rwxr-xr-x[-rw-r--r--]templates/index.php0
-rwxr-xr-x[-rw-r--r--]templates/list_articles.tpl0
-rwxr-xr-x[-rw-r--r--]templates/list_topics.tpl0
-rwxr-xr-x[-rw-r--r--]templates/menu_articles.tpl0
-rwxr-xr-x[-rw-r--r--]templates/menu_articles_admin.tpl0
-rwxr-xr-x[-rw-r--r--]templates/preview_article.tpl0
-rwxr-xr-x[-rw-r--r--]templates/print_article.tpl0
-rwxr-xr-x[-rw-r--r--]templates/read_article.tpl0
-rwxr-xr-x[-rw-r--r--]templates/submission_notification.tpl0
-rwxr-xr-x[-rw-r--r--]test/TestTikiArticle.php2
-rwxr-xr-x[-rw-r--r--]test/index.php0
65 files changed, 630 insertions, 1012 deletions
diff --git a/.hgtags b/.hgtags
index 8b79174..8b79174 100644..100755
--- a/.hgtags
+++ b/.hgtags
diff --git a/.htaccess b/.htaccess
index 400b8aa..400b8aa 100644..100755
--- a/.htaccess
+++ b/.htaccess
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' ) ),
- )),
-));
diff --git a/article_history.php b/article_history.php
index 79c7bed..cf1b040 100644..100755
--- a/article_history.php
+++ b/article_history.php
@@ -17,26 +17,27 @@
* required setup
*/
require_once '../kernel/includes/setup_inc.php';
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\KernelTools;
$gBitSystem->verifyPackage( 'articles' );
$gBitSystem->verifyPermission( 'p_articles_read' );
$gBitSystem->verifyPermission( 'p_articles_read_history' );
if( !isset( $_REQUEST["article_id"] ) ) {
- $gBitSystem->fatalError( tra( "No article indicated" ));
+ $gBitSystem->fatalError( KernelTools::tra( "No article indicated" ));
}
include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_inc.php' );
//vd($gContent->mPageId);vd($gContent->mInfo);
if( !$gContent->isValid() || empty( $gContent->mInfo ) ) {
- $gBitSystem->fatalError( tra( "Unknown article" ));
+ $gBitSystem->fatalError( KernelTools::tra( "Unknown article" ));
}
// additionally we need to check if this article is a submission and see if user has perms to view it.
if( $gContent->getField( 'status_id' ) != ARTICLE_STATUS_APPROVED && !( $gContent->hasUserPermission( 'p_articles_update_submission' ) || $gBitUser->isAdmin() ) ) {
- $gBitSmarty->assign( 'msg', tra( "Permission denied you cannot view this article" ) );
+ $gBitSmarty->assign( 'msg', KernelTools::tra( "Permission denied you cannot view this article" ) );
$gBitSystem->display( "error.tpl" , NULL, array( 'display_mode' => 'display' ));
die;
}
@@ -47,8 +48,8 @@ include_once( LIBERTY_PKG_INCLUDE_PATH.'content_history_inc.php' );
$gBitSmarty->assign( 'page', $page = !empty( $_REQUEST['list_page'] ) ? $_REQUEST['list_page'] : 1 );
$offset = ( $page - 1 ) * $gBitSystem->getConfig( 'max_records' );
$history = $gContent->getHistory( NULL, NULL, $offset, $gBitSystem->getConfig( 'max_records' ) );
-$gBitSmarty->assignByRef( 'data', $history['data'] );
-$gBitSmarty->assignByRef( 'listInfo', $history['listInfo'] );
+$gBitSmarty->assign( 'data', $history['data'] );
+$gBitSmarty->assign( 'listInfo', $history['listInfo'] );
//vd($gContent->getHistoryCount());
@@ -57,5 +58,5 @@ $numPages = ceil( $gContent->getHistoryCount() / $gBitSystem->getConfig('max_rec
$gBitSmarty->assign( 'numPages', $numPages );
// Display the template
-$gBitSmarty->assignByRef( 'gContent', $gContent );
+$gBitSmarty->assign( 'gContent', $gContent );
$gBitSystem->display( 'bitpackage:articles/article_history.tpl', NULL, array( 'display_mode' => 'display' ));
diff --git a/articles_rss.php b/articles_rss.php
index e1f8b3c..611438c 100644..100755
--- a/articles_rss.php
+++ b/articles_rss.php
@@ -16,7 +16,8 @@ $gBitSystem->verifyPackage( 'articles' );
$gBitSystem->verifyPackage( 'rss' );
$gBitSystem->verifyFeature( 'articles_rss' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\Articles\BitArticle;
+
require_once( RSS_PKG_INCLUDE_PATH.'rss_inc.php' );
$rss->title = $gBitSystem->getConfig( 'articles_rss_title', $gBitSystem->getConfig( 'site_title' ).' - '.tra( 'Articles' ) );
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
deleted file mode 100644
index 20a9f4c..0000000
--- a/bit_setup_inc.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-$registerHash = array(
- 'package_name' => 'articles',
- 'package_path' => dirname( __FILE__ ).'/',
- 'homeable' => TRUE,
-);
-$gBitSystem->registerPackage( $registerHash );
-
-if( $gBitSystem->isPackageActive( 'articles' ) ) {
-
- define( 'ARTICLE_STATUS_DENIED', 0 );
- define( 'ARTICLE_STATUS_DRAFT', 100 );
- define( 'ARTICLE_STATUS_PENDING', 200 );
- define( 'ARTICLE_STATUS_APPROVED', 300 );
- define( 'ARTICLE_STATUS_RETIRED', 400 );
-
- if( $gBitUser->hasPermission( 'p_articles_read' )) {
- $menuHash = array(
- 'package_name' => ARTICLES_PKG_NAME,
- 'index_url' => ARTICLES_PKG_URL.'index.php',
- 'menu_template' => 'bitpackage:articles/menu_articles.tpl',
- 'admin_comments_url' => ARTICLES_PKG_URL.'admin/admin_types.php',
- );
- $gBitSystem->registerAppMenu( $menuHash );
- }
-
- $gBitSystem->registerNotifyEvent( array( "article_submitted" => tra( "A user submits an article" ) ) );
-}
diff --git a/edit.php b/edit.php
index 5cd2575..57a8664 100644..100755
--- a/edit.php
+++ b/edit.php
@@ -13,7 +13,7 @@
* Initialization
*/
require_once '../kernel/includes/setup_inc.php';
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\Articles\BitArticle;
// Is package installed and enabled
$gBitSystem->verifyPackage( 'articles' );
diff --git a/edit_topic.php b/edit_topic.php
index 2081515..a239372 100644..100755
--- a/edit_topic.php
+++ b/edit_topic.php
@@ -9,7 +9,7 @@
* Initialization
*/
require_once '../kernel/includes/setup_inc.php';
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\Articles\BitArticle;
include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_topic_inc.php' );
diff --git a/icons/pkg_articles.gif b/icons/pkg_articles.gif
index 9b44dea..9b44dea 100644..100755
--- a/icons/pkg_articles.gif
+++ b/icons/pkg_articles.gif
Binary files differ
diff --git a/icons/pkg_articles.png b/icons/pkg_articles.png
index dbdb2fc..dbdb2fc 100644..100755
--- a/icons/pkg_articles.png
+++ b/icons/pkg_articles.png
Binary files differ
diff --git a/icons/rating.gif b/icons/rating.gif
index d7c40bf..d7c40bf 100644..100755
--- a/icons/rating.gif
+++ b/icons/rating.gif
Binary files differ
diff --git a/icons/rating.png b/icons/rating.png
index 804c162..804c162 100644..100755
--- a/icons/rating.png
+++ b/icons/rating.png
Binary files differ
diff --git a/icons/rating_off.gif b/icons/rating_off.gif
index c97ddf4..c97ddf4 100644..100755
--- a/icons/rating_off.gif
+++ b/icons/rating_off.gif
Binary files differ
diff --git a/icons/rating_off.png b/icons/rating_off.png
index 6d9f484..6d9f484 100644..100755
--- a/icons/rating_off.png
+++ b/icons/rating_off.png
Binary files differ
diff --git a/includes/article_filter_inc.php b/includes/article_filter_inc.php
index 8635c12..24dbbbd 100644..100755
--- a/includes/article_filter_inc.php
+++ b/includes/article_filter_inc.php
@@ -4,6 +4,9 @@
* @package articles
* @subpackage functions
*/
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\Articles\BitArticleTopic;
+use Bitweaver\Articles\BitArticleType;
if( $gBitSystem->isFeatureActive( 'articles_display_filter_bar' ) && ( $gBitUser->isAdmin() || $gBitUser->hasPermission( 'p_articles_admin' ) ) ) {
$filter['topic'][] = '';
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
new file mode 100755
index 0000000..0c9fdd8
--- /dev/null
+++ b/includes/bit_setup_inc.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * @package articles
+ */
+namespace Bitweaver\Articles;
+use Bitweaver\KernelTools;
+global $gBitSystem, $gBitUser, $gBitSmarty;
+$pRegisterHash = [
+ 'package_name' => 'articles',
+ 'package_path' => dirname( dirname( __FILE__ ) ).'/',
+ 'homeable' => true,
+];
+
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+define( 'ARTICLES_PKG_NAME', $pRegisterHash['package_name'] );
+define( 'ARTICLES_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'ARTICLES_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'ARTICLES_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
+define( 'ARTICLES_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
+define( 'ARTICLES_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+
+$gBitSystem->registerPackage( $pRegisterHash );
+
+if( $gBitSystem->isPackageActive( 'articles' ) ) {
+
+ define( 'ARTICLE_STATUS_DENIED', 0 );
+ define( 'ARTICLE_STATUS_DRAFT', 100 );
+ define( 'ARTICLE_STATUS_PENDING', 200 );
+ define( 'ARTICLE_STATUS_APPROVED', 300 );
+ define( 'ARTICLE_STATUS_RETIRED', 400 );
+
+ if( $gBitUser->hasPermission( 'p_articles_read' )) {
+ $menuHash = array(
+ 'package_name' => ARTICLES_PKG_NAME,
+ 'index_url' => ARTICLES_PKG_URL.'index.php',
+ 'menu_template' => 'bitpackage:articles/menu_articles.tpl',
+ 'admin_comments_url' => ARTICLES_PKG_URL.'admin/admin_types.php',
+ );
+ $gBitSystem->registerAppMenu( $menuHash );
+ }
+
+ $gBitSystem->registerNotifyEvent( array( "article_submitted" => KernelTools::tra( "A user submits an article" ) ) );
+}
diff --git a/includes/classes/BitArticle.php b/includes/classes/BitArticle.php
index 6b9a4e3..7b1a285 100644..100755
--- a/includes/classes/BitArticle.php
+++ b/includes/classes/BitArticle.php
@@ -21,10 +21,13 @@
/**
* Required setup
*/
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticleTopic.php' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticleType.php' );
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyMime.php' );
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' );
+namespace Bitweaver\Articles;
+use Bitweaver\BitBase;
+use Bitweaver\BitDate;
+use Bitweaver\Liberty\LibertyContent;
+use Bitweaver\Liberty\LibertyMime;
+use Bitweaver\Liberty\LibertyComment;
+use function in_array;
define( 'BITARTICLE_CONTENT_TYPE_GUID', 'bitarticle' );
@@ -39,6 +42,7 @@ class BitArticle extends LibertyMime
public $mArticleId;
public $mTypeId;
public $mTopicId;
+ public $mDate;
/**
* Initiate the articles class
@@ -55,7 +59,7 @@ class BitArticle extends LibertyMime
'content_name' => 'Article',
'handler_class' => 'BitArticle',
'handler_package' => 'articles',
- 'handler_file' => 'includes/classes/BitArticle.php',
+ 'handler_file' => 'BitArticle.php',
'maintainer_url' => 'http://www.bitweaver.org'
));
$this->mContentId = $pContentId;
@@ -133,7 +137,7 @@ class BitArticle extends LibertyMime
$this->mInfo['primary_attachment'] = &$this->mStorage[$this->mInfo['primary_attachment_id']];
}
- $this->mInfo['parsed'] = $this->parseData();
+ $this->parseData();
} else {
$this->mArticleId = NULL;
}
@@ -148,7 +152,7 @@ class BitArticle extends LibertyMime
* @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
* @access public
**/
- public function store(&$pParamHash)
+ public function store(&$pParamHash): bool
{
global $gBitSystem;
$this->StartTrans();
@@ -159,12 +163,7 @@ class BitArticle extends LibertyMime
$result = $this->mDb->associateUpdate( $table, $pParamHash['article_store'], array( "article_id" => $this->mArticleId ));
} else {
$pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
- if ( isset( $pParamHash['article_id'] )&& is_numeric( $pParamHash['article_id'] ) ) {
- // if pParamHash['article_id'] is set, someone is requesting a particular article_id. Use with caution!
- $pParamHash['article_store']['article_id'] = $pParamHash['article_id'];
- } else {
- $pParamHash['article_store']['article_id'] = $this->mDb->GenID( 'articles_article_id_seq' );
- }
+ $pParamHash['article_store']['article_id'] = ( isset( $pParamHash['article_id'] ) && is_numeric( $pParamHash['article_id'] ) ) ? $pParamHash['article_id'] : $this->mDb->GenID( 'articles_article_id_seq' );
$this->mArticleId = $pParamHash['article_store']['article_id'];
$result = $this->mDb->associateInsert( $table, $pParamHash['article_store'] );
}
@@ -176,80 +175,82 @@ class BitArticle extends LibertyMime
}
/**
- * Make sure the data is safe to store
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
- * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
- * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
- * @access private
- **/
- public function verify(&$pParamHash)
+ * Make sure the data is safe to store
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
+ * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
+ **/
+ public function verify( &$pParamHash ): bool
{
global $gBitUser, $gBitSystem;
// make sure we're all loaded up of we have a mArticleId
- if ( $this->mArticleId && empty( $this->mInfo ) ) {
+ if ($this->mArticleId && empty( $this->mInfo )) {
$this->load();
}
- if ( @$this->verifyId( $this->mInfo['content_id'] ) ) {
+ if (@$this->verifyId( $this->mInfo['content_id'] )) {
$pParamHash['content_id'] = $this->mInfo['content_id'];
}
// It is possible a derived class set this to something different
- if ( empty( $pParamHash['content_type_guid'] )&& !empty( $this->mContentTypeGuid ) ) {
+ if (empty( $pParamHash['content_type_guid'] ) && !empty( $this->mContentTypeGuid )) {
$pParamHash['content_type_guid'] = $this->mContentTypeGuid;
}
- if ( @$this->verifyId( $pParamHash['content_id'] ) ) {
+ if (@$this->verifyId( $pParamHash['content_id'] )) {
$pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
}
- if ( !empty( $pParamHash['author_name'] ) ) {
+ if (!empty( $pParamHash['author_name'] )) {
$pParamHash['article_store']['author_name'] = $pParamHash['author_name'];
}
- if ( @$this->verifyId( $pParamHash['topic_id'] ) ) {
- $pParamHash['article_store']['topic_id'] =(int) $pParamHash['topic_id'];
+ if (@$this->verifyId( $pParamHash['topic_id'] )) {
+ $pParamHash['article_store']['topic_id'] = (int) $pParamHash['topic_id'];
}
- if ( @$this->verifyId( $pParamHash['article_type_id'] ) ) {
- $pParamHash['article_store']['article_type_id'] =(int) $pParamHash['article_type_id'];
+ if (@$this->verifyId( $pParamHash['article_type_id'] )) {
+ $pParamHash['article_store']['article_type_id'] = (int) $pParamHash['article_type_id'];
}
- if ( !empty( $pParamHash['format_guid'] ) ) {
+ if (!empty( $pParamHash['format_guid'] )) {
$pParamHash['content_store']['format_guid'] = $pParamHash['format_guid'];
}
// we do the substr on load. otherwise we need to store the same data twice.
- if ( !empty( $pParamHash['edit'] ) ) {
+ if (!empty( $pParamHash['edit'] )) {
$pParamHash['content_store']['data'] = $pParamHash['edit'];
}
- if ( !empty( $pParamHash['rating'] ) ) {
- $pParamHash['article_store']['rating'] =(int) ( $pParamHash['rating'] );
+ if (!empty( $pParamHash['rating'] )) {
+ $pParamHash['article_store']['rating'] = (int) ( $pParamHash['rating'] );
}
// check for name issues, first truncate length if too long
- if ( !empty( $pParamHash['title'] ) ) {
- if ( !$this->isValid() ) {
- if ( empty( $pParamHash['title'] ) ) {
+ if (!empty( $pParamHash['title'] )) {
+ if (!$this->isValid()) {
+ if (empty( $pParamHash['title'] )) {
$this->mErrors['title'] = 'You must specify a title.';
- } else {
+ }
+ else {
$pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN );
}
- } else {
- $pParamHash['content_store']['title'] =( isset( $pParamHash['title'] ))? substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN ): '';
}
- } elseif ( empty( $pParamHash['title'] ) ) {
+ else {
+ $pParamHash['content_store']['title'] = ( isset( $pParamHash['title'] ) ) ? substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN ) : '';
+ }
+ }
+ elseif (empty( $pParamHash['title'] )) {
// no name specified
$this->mErrors['title'] = 'You must specify a title';
}
- if ( !empty( $pParamHash['publish_Month'] ) ) {
+ if (!empty( $pParamHash['publish_Month'] )) {
$dateString = $this->mDate->gmmktime(
$pParamHash['publish_Hour'],
$pParamHash['publish_Minute'],
- isset($pParamHash['publish_Second']) ? $pParamHash['publish_Second'] : 0,
+ isset( $pParamHash['publish_Second'] ) ? $pParamHash['publish_Second'] : 0,
$pParamHash['publish_Month'],
$pParamHash['publish_Day'],
$pParamHash['publish_Year']
@@ -260,15 +261,15 @@ class BitArticle extends LibertyMime
$pParamHash['publish_date'] = $timestamp;
}
}
- if ( !empty( $pParamHash['publish_date'] ) ) {
+ if (!empty( $pParamHash['publish_date'] )) {
$pParamHash['article_store']['publish_date'] = $pParamHash['publish_date'];
}
- if ( !empty( $pParamHash['expire_Month'] ) ) {
+ if (!empty( $pParamHash['expire_Month'] )) {
$dateString = $this->mDate->gmmktime(
$pParamHash['expire_Hour'],
$pParamHash['expire_Minute'],
- isset($pParamHash['expire_Second']) ? $pParamHash['expire_Second'] : 0,
+ isset( $pParamHash['expire_Second'] ) ? $pParamHash['expire_Second'] : 0,
$pParamHash['expire_Month'],
$pParamHash['expire_Day'],
$pParamHash['expire_Year']
@@ -279,50 +280,36 @@ class BitArticle extends LibertyMime
$pParamHash['expire_date'] = $timestamp;
}
}
- if ( !empty( $pParamHash['expire_date'] ) ) {
+ if (!empty( $pParamHash['expire_date'] )) {
$pParamHash['article_store']['expire_date'] = $pParamHash['expire_date'];
}
- if ( @$this->verifyId( $pParamHash['status_id'] ) ) {
- if ($pParamHash['status_id'] > ARTICLE_STATUS_PENDING) {
- if ( $gBitUser->hasPermission( 'p_articles_approve_submission' )) {
- $pParamHash['article_store']['status_id'] =(int) ( $pParamHash['status_id'] );
- } else {
- $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING;
- }
- } else {
- $pParamHash['article_store']['status_id'] =(int) ( $pParamHash['status_id'] );
- }
- } elseif ( @$this->verifyId( $this->mInfo['status_id'] ) ) {
+ if (@$this->verifyId( $pParamHash['status_id'] )) {
+ $pParamHash['article_store']['status_id'] = ( $pParamHash['status_id'] > ARTICLE_STATUS_PENDING ) ? ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) ) ? (int) ( $pParamHash['status_id'] ) : ARTICLE_STATUS_PENDING : (int) ( $pParamHash['status_id'] );
+ }
+ elseif (@$this->verifyId( $this->mInfo['status_id'] )) {
$pParamHash['article_store']['status_id'] = $this->mInfo['status_id'];
- } else {
- if ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) {
- $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_APPROVED;
- } else {
- $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING; // Default status
- }
+ }
+ else {
+ $pParamHash['article_store']['status_id'] = ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) ? ARTICLE_STATUS_APPROVED : ARTICLE_STATUS_PENDING;
}
// content preferences
$prefs = array();
- if ( $gBitUser->hasPermission( 'p_liberty_enter_html' ) ) {
+ if ($gBitUser->hasPermission( 'p_liberty_enter_html' )) {
$prefs[] = 'content_enter_html';
}
- foreach ($prefs as $pref) {
- if ( !empty( $pParamHash['preferences'][$pref] ) ) {
- $pParamHash['preferences_store'][$pref] = $pParamHash['preferences'][$pref];
- } else {
- $pParamHash['preferences_store'][$pref] = NULL;
- }
+ foreach ( $prefs as $pref ) {
+ $pParamHash['preferences_store'][$pref] = ( !empty( $pParamHash['preferences'][$pref] ) ) ? $pParamHash['preferences'][$pref] : null;
}
- if ( array_search( $pParamHash['article_store']['status_id'], array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING ) ) ) {
- $this->mInfo["no_index"] = true ;
+ if (array_search( $pParamHash['article_store']['status_id'], array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING ) )) {
+ $this->mInfo["no_index"] = true;
}
// if we have an error we get them all by checking parent classes for additional errors
- if ( count( $this->mErrors ) > 0 ) {
+ if (count( $this->mErrors ) > 0) {
parent::verify( $pParamHash );
}
@@ -366,7 +353,7 @@ class BitArticle extends LibertyMime
if ( empty( $data['parsed'] ) ) {
$data['no_cache'] = TRUE;
- $data['parsed'] = $this->parseData( $data );
+ $data['parsed'] = self::parseDataHash( $data );
// replace the split syntax with a horizontal rule
$data['parsed'] = preg_replace( LIBERTY_SPLIT_REGEX, "<hr />", $data['parsed'] );
}
@@ -381,7 +368,7 @@ class BitArticle extends LibertyMime
/**
* Get the URL for any given article image
* @param $pParamHash pass in full set of data returned from article query
- * @return url to image
+ * @return string url to image
* @access public
**/
public static function getImageThumbnails($pParamHash)
@@ -392,11 +379,10 @@ class BitArticle extends LibertyMime
$thumbHash['mime_image'] = FALSE;
if ( !empty( $pParamHash['image_attachment_path'] )) {
$thumbHash['source_file'] = $pParamHash['image_attachment_path'];
- $ret = liberty_fetch_thumbnails( $thumbHash );
+ $ret = \Bitweaver\Liberty\liberty_fetch_thumbnails( $thumbHash );
} elseif ( !empty( $pParamHash['has_topic_image'] ) && $pParamHash['has_topic_image'] == 'y' ) {
-return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
$thumbHash['source_file'] = preg_replace( "#^/+#", "", BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] ));
- $ret = liberty_fetch_thumbnails( $thumbHash );
+ $ret = \Bitweaver\Liberty\liberty_fetch_thumbnails( $thumbHash );
}
return $ret;
@@ -407,7 +393,7 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
* @return bool TRUE on success, FALSE on failure
* @access public
**/
- public function expunge()
+ public function expunge(): bool
{
$ret = FALSE;
if ( $this->isValid() ) {
@@ -588,11 +574,11 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* Returns include file that will setup vars for display
- * @return the fully specified path to file to be included
+ * @return string the fully specified path to file to be included
*/
public function getRenderFile()
{
- return ARTICLES_PKG_INCLUDE_PATH.'display_article_inc.php';
+ return ARTICLES_PKG_PATH."display_article_inc.php";
}
/**
@@ -623,13 +609,13 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* Generates the URL to the article
- * @return the link to the full article
+ * @return string the link to the full article
*/
public static function getDisplayUrlFromHash(&$pParamHash)
{
global $gBitSystem;
- $ret = NULL;
+ $ret = '';
if ( @BitBase::verifyId( $pParamHash['article_id'] ) ) {
if ( $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
@@ -647,7 +633,7 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* Function that returns link to display an image
- * @return the url to display the gallery.
+ * @return string the url to display the gallery.
*/
public function getDisplayUrl()
{
@@ -657,10 +643,10 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
/**
* get a list of all available statuses
- * @return an array of available statuses
+ * @return array of available statuses
* @access public
**/
- public function getStatusList()
+ public static function getStatusList()
{
global $gBitSystem;
$query = "SELECT * FROM `".BIT_DB_PREFIX."article_status`";
@@ -672,13 +658,13 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
* set the status of an article
* @param $pStatusId new status id of the article
* @param $pArticleId of the article that is being changed - if not set, it will attemtp to change the currently loaded article
- * @return new status of article on success - else returns NULL
+ * @return int new status of article on success - else returns NULL
* @access public
**/
public function setStatus($pStatusId, $pArticleId = NULL, $pContentId = NULL)
{
global $gBitSystem;
- $validStatuses = array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING, ARTICLE_STATUS_APPROVED, ARTICLE_STATUS_RETIRED );
+ $validStatuses = [ ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING, ARTICLE_STATUS_APPROVED, ARTICLE_STATUS_RETIRED ];
if ( !in_array( $pStatusId, $validStatuses ) ) {
$this->mErrors[] = "Invalid article status";
@@ -701,12 +687,13 @@ return BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] );
if ( $gBitSystem->isPackageActive( 'search' ) ) {
include_once( SEARCH_PKG_PATH.'refresh_functions.php' );
if ($pStatusId == ARTICLE_STATUS_APPROVED) {
- refresh_index($this);
+ \Bitweaver\Liberty\refresh_index($this);
} elseif (!$pStatusId == ARTICLE_STATUS_RETIRED) {
- delete_index($pContentId); // delete it from the search index unless retired ...
+ \Bitweaver\Liberty\delete_index($pContentId); // delete it from the search index unless retired ...
}
}
return $pStatusId;
}
+ return false;
}
}
diff --git a/includes/classes/BitArticleTopic.php b/includes/classes/BitArticleTopic.php
index 1422508..c651dee 100644..100755
--- a/includes/classes/BitArticleTopic.php
+++ b/includes/classes/BitArticleTopic.php
@@ -11,35 +11,40 @@
/**
* Required setup
*/
-global $gBitSystem;
-require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+namespace Bitweaver\Articles;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
/**
* @package articles
*/
-class BitArticleTopic extends BitBase {
- var $mTopicId;
+class BitArticleTopic extends BitBase
+{
+ public $mTopicId;
+ public $mArticleId;
- function __construct($iTopicId = NULL, $iTopicName = NULL) {
+ public function __construct($iTopicId = NULL, $iTopicName = NULL)
+ {
$this->mTopicId = NULL;
parent::__construct();
if ($iTopicId || $iTopicName) {
- $this->loadTopic(array('topic_id'=>$iTopicId, 'topic_name'=>$iTopicName));
+ $this->loadTopic( [ 'topic_id' => $iTopicId, 'topic_name' => $iTopicName ]);
}
}
- function isValid() {
+ public function isValid()
+ {
return ($this->verifyId($this->mTopicId));
}
- function loadTopic($iParamHash = NULL) {
+ public function loadTopic($iParamHash = NULL)
+ {
$whereSQL = ' WHERE artt.';
$ret = NULL;
if (@$this->verifyId($iParamHash['topic_id']) || !empty($iParamHash['topic_name'])) {
$whereSQL .= "`".((@$this->verifyId($iParamHash['topic_id']) || $this->mTopicId) ? 'topic_id' : 'topic_name')."` = ?";
- $bindVars = array((@$this->verifyId($iParamHash['topic_id']) ? (int)$iParamHash['topic_id'] : ($this->mTopicId ? $this->mTopicId : $iParamHash['topic_name'])) );
+ $bindVars = [ ( @$this->verifyId( $iParamHash['topic_id'] ) ? (int) $iParamHash['topic_id'] : ( $this->mTopicId ?: $iParamHash['topic_name'] ) ) ];
$sql = "SELECT artt.*".
"FROM `".BIT_DB_PREFIX."article_topics` artt ".
@@ -49,49 +54,35 @@ class BitArticleTopic extends BitBase {
if( !empty( $this->mInfo['topic_id'] ) ) {
$this->mTopicId = $this->mInfo['topic_id'];
- if ($this->mInfo['has_topic_image']) {
- $this->mInfo['topic_image_url'] = static::getTopicImageStorageUrl($this->mTopicId, FALSE, TRUE);
- } else {
- $this->mInfo['topic_image_url'] = NULL;
- }
+ $this->mInfo['topic_image_url'] = ( $this->mInfo['has_topic_image'] ) ? $this->getTopicImageStorageUrl( null, false, true ) : null;
}
}
return $ret;
}
- function verify(&$iParamHash) {
+ public function verify(&$iParamHash)
+ {
// Validate the (optional) topic_id parameter
- if (@$this->verifyId($iParamHash['topic_id'])) {
- $cleanHash['topic_id'] = (int)$iParamHash['topic_id'];
- } else {
- $cleanHash['topic_id'] = NULL;
- }
+ $cleanHash['topic_id'] = ( @$this->verifyId( $iParamHash['topic_id'] ) ) ? (int) $iParamHash['topic_id'] : null;
// Was an acceptable name given?
if (empty($iParamHash['topic_name']) || ($iParamHash['topic_name'] == '')) {
- $this->mErrors['topic_name'] = tra("Invalid or blank topic name supplied");
- } else if (empty($iParamHash['topic_id'])) {
- $ret = $this->getTopicList( array( 'topic_name' => $iParamHash['topic_name'] ) );
+ $this->mErrors['topic_name'] = KernelTools::tra("Invalid or blank topic name supplied");
+ } elseif (empty($iParamHash['topic_id'])) {
+ $ret = $this->getTopicList( [ 'topic_name' => $iParamHash['topic_name'] ] );
if ( sizeof( $ret ) ) {
$this->mErrors['topic_name'] = 'Topic "'.$iParamHash['topic_name'].'" already exists. Please choose a different name.';
} else {
$cleanHash['topic_name'] = $iParamHash['topic_name'];
}
- }
- else {
+ } else {
$cleanHash['topic_name'] = $iParamHash['topic_name'];
}
-
// Whether the topic is active or not
if ( empty($iParamHash['active_topic']) || (strtoupper($iParamHash['active_topic']) != 'CHECKED' && strtoupper($iParamHash['active_topic']) != 'ON' && strtoupper($iParamHash['active_topic']) != 'Y')) {
- if (@$this->verifyId($cleanHash['topic_id'])) {
- $cleanHash['active_topic'] = 'n';
- } else {
- // Probably a new topic so lets go ahead and enable it
- $cleanHash['active_topic'] = 'y';
- }
+ $cleanHash['active_topic'] = ( @$this->verifyId( $cleanHash['topic_id'] ) ) ? 'n' : 'y';
} else {
$cleanHash['active_topic'] = 'y';
}
@@ -106,28 +97,25 @@ class BitArticleTopic extends BitBase {
return(count($this->mErrors) == 0);
}
- function storeTopic($iParamHash = NULL) {
+ public function storeTopic($iParamHash = NULL)
+ {
global $gLibertySystem;
global $gBitUser;
if ($this->verify($iParamHash)) {
- if (!$iParamHash['topic_id']) {
- $topicId = $this->mDb->GenID('article_topics_id_seq');
- } else {
- $topicId = $this->mTopicId;
- }
+ $topicId = ( !$iParamHash['topic_id'] ) ? $this->mDb->GenID( 'article_topics_id_seq' ) : $this->mTopicId;
if( !empty( $_FILES['upload'] ) && $_FILES['upload']['tmp_name'] ) {
- $checkFunc = liberty_get_function( 'can_thumbnail' );
+ $checkFunc = \Bitweaver\Liberty\liberty_get_function( 'can_thumbnail' );
if( $checkFunc( $_FILES['upload']['type'] )) {
$fileHash = $_FILES['upload'];
$fileHash['dest_branch'] = $this->getTopicImageBaseUrl( $topicId );
$fileHash['source_file'] = $fileHash['tmp_name'];
- liberty_clear_thumbnails( $fileHash );
- liberty_generate_thumbnails( $fileHash );
+ \Bitweaver\Liberty\liberty_clear_thumbnails( $fileHash );
+ \Bitweaver\Liberty\liberty_generate_thumbnails( $fileHash );
$iParamHash['has_topic_image'] = 'y';
} else {
- $this->mErrors = tra( "The file you uploaded doesn't appear to be a valid image. The reported mime type is" ).": ".$_FILES['upload']['type'];
+ $this->mErrors = KernelTools::tra( "The file you uploaded doesn't appear to be a valid image. The reported mime type is" ).": ".$_FILES['upload']['type'];
}
}
@@ -145,17 +133,18 @@ class BitArticleTopic extends BitBase {
* Work out the path to the image for this article
* @param $pTopicId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return path on success, FALSE on failure
+ * @return string on success, FALSE on failure
* @access public
**/
- function getTopicImageBaseUrl( $pTopicId = NULL ) {
+ public function getTopicImageBaseUrl($pTopicId = NULL)
+ {
$ret = FALSE;
- if( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
+ if ( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
$pTopicId = $this->mTopicId;
}
if( @BitBase::verifyId( $pTopicId )) {
- $ret = LibertyMime::getStorageUrl( 'topics/'.$pTopicId );
+ $ret = \Bitweaver\Liberty\liberty_mime_get_storage_branch( 'topics/'.$pTopicId );
}
return $ret;
}
@@ -165,22 +154,32 @@ class BitArticleTopic extends BitBase {
*
* @param numeric $pTopicId Topic ID of topic in question
* @access public
- * @return Path to thumbnail, FALSE on failure
+ * @return string Path to thumbnail, FALSE on failure
*/
- public static function getTopicImageThumbUrl( $pTopicId ) {
+ public function getTopicImageThumbUrl($pTopicId = NULL)
+ {
+ global $gBitSystem;
$ret = FALSE;
- if( @BitBase::verifyId( $pTopicId )) {
- $ret = STORAGE_PKG_URL.ARTICLES_PKG_NAME.'/topic_'.$pTopicId.'.jpg';
+ if ( !@BitBase::verifyId( $pTopicId ) && $this->isValid() ) {
+ $pTopicId = $this->mTopicId;
+ }
+
+ if ( @BitBase::verifyId( $pTopicId )) {
+ $ret = \Bitweaver\Liberty\liberty_fetch_thumbnail_url( [
+ 'source_file' => BitArticleTopic::getTopicImageBaseUrl( $pTopicId ),
+ 'default_image' => $gBitSystem->getConfig( 'articles_image_size', 'small' ),
+ ]);
}
return $ret;
}
- public static function getTopicList( $pOptionHash=NULL ) {
+ public static function getTopicList($pOptionHash=NULL)
+ {
global $gBitSystem;
$where = '';
- $bindVars = array();
- if( !empty( $pOptionHash['active_topic'] ) ) {
+ $bindVars = [];
+ if ( !empty( $pOptionHash['active_topic'] ) ) {
$where = " WHERE artt.`active_topic` = 'y' ";
}
if ( !empty( $pOptionHash['topic_name'] ) ) {
@@ -194,12 +193,12 @@ class BitArticleTopic extends BitBase {
$result = $gBitSystem->mDb->query( $query, $bindVars );
- $ret = array();
+ $ret = [];
- while( $res = $result->fetchRow() ) {
- $res["num_articles"] = $gBitSystem->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."articles` WHERE `topic_id`= ?", array( $res["topic_id"] ) );
- if( empty( $res['topic_image_url'] ) && $res['has_topic_image'] == 'y' ) {
- $res['topic_image_url'] = static::getTopicImageStorageUrl( $res['topic_id'] );
+ while ( $res = $result->fetchRow() ) {
+ $res["num_articles"] = $gBitSystem->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."articles` WHERE `topic_id`= ?", [ $res["topic_id"] ] );
+ if ( empty( $res['topic_image_url'] ) && $res['has_topic_image'] == 'y' ) {
+ $res['topic_image_url'] = BitArticleTopic::getTopicImageStorageUrl( $res['topic_id'] );
}
$ret[] = $res;
@@ -208,9 +207,10 @@ class BitArticleTopic extends BitBase {
return $ret;
}
- function removeTopicImage() {
- if( $this->mTopicId ) {
- if( file_exists($this->getTopicImageStoragePath() ) ) {
+ public function removeTopicImage()
+ {
+ if ($this->mTopicId) {
+ if ( file_exists($this->getTopicImageStoragePath() ) ) {
@unlink( $this->getTopicImageStoragePath() );
}
$sql = "UPDATE `".BIT_DB_PREFIX."article_topics` SET `has_topic_image` = 'n' WHERE `topic_id` = ?";
@@ -219,29 +219,33 @@ class BitArticleTopic extends BitBase {
}
}
- function activateTopic() {
+ public function activateTopic()
+ {
$this->setActivation(TRUE);
}
- function deactivateTopic() {
+ public function deactivateTopic()
+ {
$this->setActivation(FALSE);
}
- function setActivation($iIsActive = FALSE) {
+ public function setActivation($iIsActive = FALSE)
+ {
$sql = "UPDATE `".BIT_DB_PREFIX."article_topics` SET `active_topic` = '".($iIsActive ? 'y' : 'n')."' WHERE `topic_id` = ?";
$rs = $this->mDb->query($sql, array($this->mTopicId));
$this->mInfo['active_topic'] = ($iIsActive ? 'y' : 'n');
}
- function getTopicArticles() {
+ public function getTopicArticles()
+ {
if (!$this->mTopicId) {
- return NULL;
+ return [];
}
$sql = "SELECT `article_id` FROM `".BIT_DB_PREFIX."articles` WHERE `topic_id` = ?";
- $rs = $this->mDb->query($sql, array($this->mTopicId));
+ $rs = $this->mDb->query($sql, [ $this->mTopicId ]);
- $ret = array();
+ $ret = [];
while ($row = $rs->fetchRow()) {
$tmpArticle = new BitArticle($row['article_id']);
$tmpArticle->load();
@@ -249,7 +253,8 @@ class BitArticleTopic extends BitBase {
}
}
- function removeTopic($iRemoveArticles = FALSE) {
+ public function removeTopic($iRemoveArticles = FALSE)
+ {
if (!$this->mTopicId) {
return NULL;
}
@@ -263,11 +268,11 @@ class BitArticleTopic extends BitBase {
}
} else {
$sql = "UPDATE `".BIT_DB_PREFIX."articles` SET `topic_id` = ? WHERE `topic_id` = ?";
- $rs = $this->mDb->query($sql, array(NULL, $this->mTopicId));
+ $rs = $this->mDb->query($sql, [ null, $this->mTopicId ]);
}
$sql = "DELETE FROM `".BIT_DB_PREFIX."article_topics` WHERE `topic_id` = ?";
- $rs = $this->mDb->query($sql, array($this->mTopicId));
+ $rs = $this->mDb->query($sql, [ $this->mTopicId ]);
}
@@ -284,14 +289,15 @@ class BitArticleTopic extends BitBase {
*
* @param array $pTopicId article id
* @access public
- * @return TRUE on success, FALSE on failure
+ * @return string on success
*/
- function getTopicImageStorageName( $pTopicId = NULL ) {
- if( !@BitBase::verifyId( $pTopicId ) ) {
- if( $this->isValid() ) {
+ public function getTopicImageStorageName($pTopicId = NULL)
+ {
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( $this->isValid() ) {
$pTopicId = $this->mTopicId;
} else {
- return NULL;
+ return '';
}
}
@@ -303,28 +309,29 @@ class BitArticleTopic extends BitBase {
* Work out the path to the image for this article
* @param $pTopicId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return path on success, FALSE on failure
+ * @return string path on success, FALSE on failure
* @access public
**/
- function getTopicImageStoragePath( $pTopicId = NULL, $pBasePathOnly = FALSE ) {
- $path = static::getArticleImageStoragePath( NULL, TRUE );
+ public function getTopicImageStoragePath($pTopicId = NULL, $pBasePathOnly = FALSE)
+ {
+ $path = BitArticleTopic::getArticleImageStoragePath( NULL, TRUE );
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $path;
}
- if( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
if( $this->isValid() ) {
$pTopicId = $this->mTopicId;
} else {
- return NULL;
+ return '';
}
}
- if( !empty( $pTopicId ) ) {
- return $path.static::getTopicImageStorageName( $pTopicId );
+ if ( !empty( $pTopicId ) ) {
+ return $path.BitArticleTopic::getTopicImageStorageName( $pTopicId );
} else {
- return FALSE;
+ return '';
}
}
@@ -332,22 +339,31 @@ class BitArticleTopic extends BitBase {
* Work out the URL to the image for this article
* @param $pTopicId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return URL on success, FALSE on failure
+ * @return string URL on success, FALSE on failure
* @access public
**/
- public static function getTopicImageStorageUrl( $pTopicId, $pBasePathOnly = FALSE, $pForceRefresh = FALSE ) {
+ public function getTopicImageStorageUrl($pTopicId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE)
+ {
global $gBitSystem;
- $ret = FALSE;
+ $ret = false;
// first we check to see if this is a new type thumbnail. if that fails we'll use the old method
- if( !( $ret = static::getTopicImageThumbUrl( $pTopicId ))) {
- $url = static::getArticleImageStorageUrl( $this->mArticleId, NULL, TRUE );
- if( $pBasePathOnly ) {
+ if ( !( $ret = BitArticleTopic::getTopicImageThumbUrl( $pTopicId ))) {
+ $url = BitArticleTopic::getArticleImageStorageUrl( NULL, TRUE );
+ if ($pBasePathOnly) {
return $url;
}
- if( is_file( static::getTopicImageStoragePath( NULL, TRUE ).static::getTopicImageStorageName( $pTopicId ))) {
- $ret = $url.static::getTopicImageStorageName( $pTopicId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ if ( !@BitBase::verifyId( $pTopicId ) ) {
+ if ( $this->isValid() ) {
+ $pTopicId = $this->mTopicId;
+ } else {
+ return false;
+ }
+ }
+
+ if ( is_file( BitArticleTopic::getTopicImageStoragePath( NULL, TRUE ).BitArticleTopic::getTopicImageStorageName( $pTopicId ))) {
+ $ret = $url.BitArticleTopic::getTopicImageStorageName( $pTopicId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
}
}
@@ -373,30 +389,36 @@ class BitArticleTopic extends BitBase {
*
* @param array $pArticleId article id
* @access public
- * @return TRUE on success, FALSE on failure
+ * @return string on success, FALSE on failure
*/
- public function getArticleImageStorageName( $pArticleId ) {
- $ret = FALSE;
- if( BitBase::verifyId( $pArticleId ) ) {
- $ret = "article_$pArticleId.jpg";
+ public function getArticleImageStorageName($pArticleId = NULL)
+ {
+ if ( !@BitBase::verifyId( $pArticleId ) ) {
+ if ( $this->isValid() ) {
+ $pArticleId = $this->mArticleId;
+ } else {
+ return NULL;
+ }
}
- return $ret;
+
+ return "article_$pArticleId.jpg";
}
/**
* Work out the path to the image for this article
* @param $pArticleId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return path on success, FALSE on failure
+ * @return string path on success, FALSE on failure
* @access public
**/
- function getArticleImageStoragePath( $pArticleId = NULL, $pBasePathOnly = FALSE ) {
+ public function getArticleImageStoragePath($pArticleId = NULL, $pBasePathOnly = FALSE)
+ {
$path = STORAGE_PKG_PATH.ARTICLES_PKG_NAME.'/';
- if( !is_dir( $path ) ) {
- mkdir_p( $path );
+ if ( !is_dir( $path ) ) {
+ KernelTools::mkdir_p( $path );
}
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $path;
}
@@ -408,8 +430,8 @@ class BitArticleTopic extends BitBase {
}
}
- if( !empty( $pArticleId ) ) {
- return $path.static::getArticleImageStorageName( $pArticleId );
+ if ( !empty( $pArticleId ) ) {
+ return $path.BitArticleTopic::getArticleImageStorageName( $pArticleId );
} else {
return FALSE;
}
@@ -419,24 +441,29 @@ class BitArticleTopic extends BitBase {
* Work out the URL to the image for this article
* @param $pArticleId id of the article we need the image path for
* @param $pBasePathOnly bool TRUE / FALSE - specify whether you want full path or just base path
- * @return URL on success, FALSE on failure
+ * @return string URL on success, FALSE on failure
* @access public
**/
- public static function getArticleImageStorageUrl( $pArticleId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE ) {
+ public function getArticleImageStorageUrl($pArticleId = NULL, $pBasePathOnly = FALSE, $pForceRefresh = FALSE)
+ {
global $gBitSystem;
-
- $ret = FALSE;
$url = STORAGE_PKG_URL.ARTICLES_PKG_NAME.'/';
- if( $pBasePathOnly ) {
+ if ($pBasePathOnly) {
return $url;
}
- if( BitBase::verifyId( $pArticleId ) ) {
- if( is_file( static::getArticleImageStoragePath( NULL, TRUE ).static::getArticleImageStorageName( $pArticleId ) ) ) {
- $ret = $url.static::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ if( !@BitBase::verifyId( $pArticleId ) ) {
+ if( $this->isValid() ) {
+ $pArticleId = $this->mArticleId;
+ } else {
+ return NULL;
}
}
- return $ret;
+
+ if ( is_file( BitArticleTopic::getArticleImageStoragePath( NULL, TRUE ).BitArticleTopic::getArticleImageStorageName( $pArticleId ) ) ) {
+ return $url.BitArticleTopic::getArticleImageStorageName( $pArticleId ).( $pForceRefresh ? "?".$gBitSystem->getUTCTime() : '' );
+ } else {
+ return FALSE;
+ }
}
}
-
diff --git a/includes/classes/BitArticleType.php b/includes/classes/BitArticleType.php
index 42fa209..ac45427 100644..100755
--- a/includes/classes/BitArticleType.php
+++ b/includes/classes/BitArticleType.php
@@ -11,8 +11,9 @@
/**
* Required setup
*/
-require_once( KERNEL_PKG_CLASS_PATH.'BitBase.php' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+namespace Bitweaver\Articles;
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
/**
* @package articles
@@ -20,6 +21,7 @@ require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
class BitArticleType extends BitBase
{
public $mTypeId;
+ public $mTopicId;
public function __construct($iTypeId = NULL)
{
@@ -46,8 +48,8 @@ class BitArticleType extends BitBase
if ($this->mTypeId) {
$sql = "SELECT * FROM `".BIT_DB_PREFIX."article_types` WHERE `article_type_id` = ?";
- if( $ret = $this->mDb->getRow( $sql, array( $this->mTypeId ) ) ) {
- $ret['num_articles'] = $this->mDb->getOne('SELECT COUNT(*) FROM `'.BIT_DB_PREFIX.'articles` WHERE `article_type_id` = ?', array($ret['article_type_id']));
+ if( $ret = $this->mDb->getRow( $sql, [ $this->mTypeId ] ) ) {
+ $ret['num_articles'] = $this->mDb->getOne('SELECT COUNT(*) FROM `'.BIT_DB_PREFIX.'articles` WHERE `article_type_id` = ?', [ $ret['article_type_id'] ] );
}
}
$this->mInfo = $ret;
@@ -86,7 +88,7 @@ class BitArticleType extends BitBase
} else {
// Was an acceptable name given?
if (empty($iParamHash['type_name']) || ($iParamHash['type_name'] == '')) {
- $this->mErrors['type_name'] = tra("Invalid or blank article type name supplied");
+ $this->mErrors['type_name'] = KernelTools::tra("Invalid or blank article type name supplied");
} else {
$cleanHash['type_name'] = $iParamHash['type_name'];
}
@@ -102,18 +104,10 @@ class BitArticleType extends BitBase
global $gBitUser;
if ($this->verify($iParamHash)) {
- if (!$iParamHash['article_type_id']) {
- if (empty($this->mTopicId)) {
- $typeId = $this->mDb->GenID('article_types_id_seq');
- } else {
- $typeId = $this->mTopicId;
- }
- } else {
- $typeId = $iParamHash['article_type_id'];
- }
+ $typeId = ( !$iParamHash['article_type_id'] ) ? ( empty( $this->mTopicId ) ) ? $this->mDb->GenID( 'article_types_id_seq' ) : $this->mTopicId : $iParamHash['article_type_id'];
if ($iParamHash['article_type_id']) {
- $this->mDb->associateUpdate(BIT_DB_PREFIX."article_types", $iParamHash, array( 'article_type_id'=> $iParamHash['article_type_id']));
+ $this->mDb->associateUpdate(BIT_DB_PREFIX."article_types", $iParamHash, [ 'article_type_id'=> $iParamHash['article_type_id'] ] );
} else {
$iParamHash['article_type_id'] = $typeId;
$this->mDb->associateInsert(BIT_DB_PREFIX."article_types", $iParamHash);
@@ -126,7 +120,7 @@ class BitArticleType extends BitBase
{
if (!$iTypeId) {
if (!$this->mTypeId) {
- $this->mErrors[] = tra("Invalid type id given");
+ $this->mErrors[] = KernelTools::tra("Invalid type id given");
return NULL;
} else {
$iTypeId = $this->mTypeId;
@@ -136,7 +130,7 @@ class BitArticleType extends BitBase
}
$sql = "DELETE FROM `".BIT_DB_PREFIX."article_types` WHERE `article_type_id` = ?";
- $rs = $this->mDb->query($sql, array($iTypeId));
+ $rs = $this->mDb->query($sql, [$iTypeId]);
}
public static function getTypeList()
@@ -144,11 +138,11 @@ class BitArticleType extends BitBase
global $gBitSystem;
$query = "SELECT * FROM `" . BIT_DB_PREFIX . "article_types`";
- $result = $gBitSystem->mDb->query( $query, array() );
- $ret = array();
+ $result = $gBitSystem->mDb->query( $query, [] );
+ $ret = [];
while ( $res = $result->fetchRow() ) {
- $res['article_cnt'] = $gBitSystem->mDb->getOne( "select count(*) from `" . BIT_DB_PREFIX . "articles` where `article_type_id` = ?", array( $res['article_type_id'] ) );
+ $res['article_cnt'] = $gBitSystem->mDb->getOne( "select count(*) from `" . BIT_DB_PREFIX . "articles` where `article_type_id` = ?", [ $res['article_type_id'] ] );
$ret[] = $res;
}
diff --git a/includes/display_article_inc.php b/includes/display_article_inc.php
index 3a884bf..7f73f59 100644..100755
--- a/includes/display_article_inc.php
+++ b/includes/display_article_inc.php
@@ -8,18 +8,19 @@
/**
* Initialization
*/
-$gBitSmarty->assignByRef( 'article', $gContent->mInfo );
+ use Bitweaver\Articles\BitArticleTopic;
+$gBitSmarty->assign( 'article', $gContent->mInfo );
// get all the services that want to display something on this page
-$displayHash = array( 'perm_name' => 'p_articles_read' );
+$displayHash = [ 'perm_name' => 'p_articles_read' ];
$gContent->invokeServices( 'content_display_function', $displayHash );
$topics = BitArticleTopic::getTopicList();
-$gBitSmarty->assignByRef( 'topics', $topics );
+$gBitSmarty->assign( 'topics', $topics );
// Comments engine!
if( @$gContent->mInfo['allow_comments'] == 'y' ) {
- $comments_vars = Array( 'article' );
+ $comments_vars = [ 'article' ];
$comments_prefix_var='article:';
$comments_object_var='article';
$commentsParentId = $gContent->mContentId;
@@ -28,4 +29,4 @@ if( @$gContent->mInfo['allow_comments'] == 'y' ) {
}
// Display the Index Template
-$gBitSystem->display( 'bitpackage:articles/read_article.tpl', @$gContent->mInfo['title'] , array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:articles/read_article.tpl', @$gContent->mInfo['title'] , [ 'display_mode' => 'display' ]);
diff --git a/includes/lookup_article_inc.php b/includes/lookup_article_inc.php
index 75dfb92..cdd5902 100644..100755
--- a/includes/lookup_article_inc.php
+++ b/includes/lookup_article_inc.php
@@ -8,7 +8,8 @@
/**
* Initialization
*/
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php');
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\BitBase;
require_once( LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php' );
// if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
diff --git a/includes/lookup_article_topic_inc.php b/includes/lookup_article_topic_inc.php
index 373164c..08b55fc 100644..100755
--- a/includes/lookup_article_topic_inc.php
+++ b/includes/lookup_article_topic_inc.php
@@ -9,20 +9,17 @@
* Initialization
*/
global $gContent;
- require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php');
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\Articles\BitArticleTopic;
// if we already have a gContent, we assume someone else created it for us, and has properly loaded everything up.
if( empty( $gContent ) || !is_object( $gContent ) ) {
- if (!empty($_REQUEST['topic_id']) && is_numeric($_REQUEST['topic_id'])) {
- $gContent = new BitArticleTopic( $_REQUEST['topic_id'] );
- } else {
- $gContent = new BitArticleTopic();
- }
+ $gContent = ( !empty( $_REQUEST['topic_id'] ) && is_numeric( $_REQUEST['topic_id'] ) ) ? new BitArticleTopic( $_REQUEST['topic_id'] ) : new BitArticleTopic();
if( empty( $gContent->mTopicId ) ) {
//handle legacy forms that use plain 'article' form variable name
} else {
$gContent->loadTopic();
}
- $gBitSmarty->assignByRef( 'gContent', $gContent );
+ $gBitSmarty->assign( 'gContent', $gContent );
}
diff --git a/index.php b/index.php
index 232ee67..41baab2 100644..100755
--- a/index.php
+++ b/index.php
@@ -4,24 +4,28 @@
// 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.
-// Initialization
+/**
+ * required setup
+ */
+namespace Bitweaver\Articles;
+use Bitweaver\KernelTools;
+
require_once '../kernel/includes/setup_inc.php';
// Is package installed and enabled
$gBitSystem->verifyPackage( 'articles' );
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_articles_read' );
if ( !empty( $_REQUEST['article_id'] ) ) {
- $param = array ( 'article_id' => (int) $_REQUEST['article_id'] );
- bit_redirect( BitArticle::getDisplayUrlFromHash( $param ) );
+ $param = [ 'article_id' => (int) $_REQUEST['article_id'] ];
+ KernelTools::bit_redirect( BitArticle::getDisplayUrlFromHash( $param ) );
}
// Display the template
-$gDefaultCenter = 'bitpackage:articles/center_display_articles.tpl';
-$gBitSmarty->assignByRef( 'gDefaultCenter', $gDefaultCenter );
+$gDefaultCenter = 'bitpackage:articles/center_list_articles.tpl';
+$gBitSmarty->assign( 'gDefaultCenter', $gDefaultCenter );
// Display the template
-$gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', tra( 'Articles' ) , array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:kernel/dynamic.tpl', KernelTools::tra( 'Articles' ) , array( 'display_mode' => 'display' ));
diff --git a/liberty_plugins/data.articles.php b/liberty_plugins/data.articles.php
index da7a1bd..bcbf334 100644..100755
--- a/liberty_plugins/data.articles.php
+++ b/liberty_plugins/data.articles.php
@@ -20,24 +20,27 @@
// +----------------------------------------------------------------------+
// $Id$
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\KernelTools;
+
/**
* definitions
*/
global $gBitSystem, $gBitSmarty;
define( 'PLUGIN_GUID_DATAARTICLES', 'dataarticles' );
global $gLibertySystem;
-$pluginParams = array (
- 'tag' => 'ARTICLES',
- 'auto_activate' => FALSE,
- 'requires_pair' => FALSE,
+$pluginParams = [
+ 'tag' => 'ARTICLES',
+ 'auto_activate' => false,
+ 'requires_pair' => false,
'load_function' => 'data_articles',
'help_function' => 'data_articles_help',
- 'title' => 'Articles',
- 'help_page' => 'DataPluginArticles',
- 'description' => tra( "This plugin will display several Articles." ),
- 'syntax' => "{ARTICLES max= topic= type= }",
- 'plugin_type' => DATA_PLUGIN
-);
+ 'title' => 'Articles',
+ 'help_page' => 'DataPluginArticles',
+ 'description' => KernelTools::tra( "This plugin will display several Articles." ),
+ 'syntax' => "{ARTICLES max= topic= type= }",
+ 'plugin_type' => DATA_PLUGIN,
+];
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAARTICLES, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLES );
@@ -45,35 +48,33 @@ $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAARTICLES
function data_articles_help()
{
$help =
- '<table class="data help">'
- .'<tr>'
- .'<th>' . tra( "Key" ) . '</th>'
- .'<th>' . tra( "Type" ) . '</th>'
- .'<th>' . tra( "Comments" ) . '</th>'
+ "<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>max</td>'
- .'<td>' . tra( "numeric") . '<br />' . tra("(optional)") . '</td>'
- .'<td>' . tra( "The number of Articles to be displayed. (Default = 3)") . '</td>'
+ .'<td>' . KernelTools::tra( "numeric") . '<br />' . KernelTools::tra("(optional)") . '</td>'
+ .'<td>' . KernelTools::tra( "The number of Articles to be displayed. (Default = 3)") . '</td>'
.'</tr>'
.'<tr class="even">'
.'<td>topic</td>'
- .'<td>' . tra( "topic name") . '<br />' . tra("(optional)") . '</td>'
- .'<td>' . tra( "Filters the Articles so that only the Topic specified is displayed") . '</td>'
+ .'<td>' . KernelTools::tra( "topic name") . '<br />' . KernelTools::tra("(optional)") . '</td>'
+ .'<td>' . KernelTools::tra( "Filters the Articles so that only the Topic specified is displayed") . '</td>'
.'</tr>'
.'<tr class="odd">'
.'<td>type</td>'
- .'<td>' . tra( "type name") . '<br />' . tra("(optional)") . '</td>'
- .'<td>' . tra( "Filters the Articles so that only the Type specified is displayed") . '</td>'
+ .'<td>' . KernelTools::tra( "type name") . '<br />' . KernelTools::tra("(optional)") . '</td>'
+ .'<td>' . KernelTools::tra( "Filters the Articles so that only the Type specified is displayed") . '</td>'
.'</tr>'
.'<tr class="even">'
.'<td>format</td>'
- .'<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
- .'<td>' . tra( "Specify format for article display - options: full, list (default)") . '</td>'
+ .'<td>' . KernelTools::tra( "string") . '<br />' . KernelTools::tra("(optional)") . '</td>'
+ .'<td>' . KernelTools::tra( "Specify format for article display - options: full, list (default)") . '</td>'
.'</tr>'
.'</table>'
- . tra("Example: ") . "{ARTICLES max=5 topic='some_topic'}<br />"
- . tra("Example: ") . "{ARTICLES max=5 type='some_type'}";
+ . KernelTools::tra("Example: ") . "{ARTICLES max=5 topic='some_topic'}<br />"
+ . KernelTools::tra("Example: ") . "{ARTICLES max=5 type='some_type'}";
return $help;
}
@@ -84,17 +85,12 @@ function data_articles($data, $params) { // No change in the parameters with Cly
// The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
$pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATAARTICLES];
- require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php');
require_once( LIBERTY_PKG_INCLUDE_PATH.'lookup_content_inc.php' );
$module_params = $params;
$articlesObject = new BitArticle();
$stati = array( 'pending', 'approved' );
- if( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) {
- $status_id = constant( 'ARTICLE_STATUS_'.strtoupper( $module_params['status'] ) );
- } else {
- $status_id = ARTICLE_STATUS_APPROVED;
- }
+ $status_id = ( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) ? constant( 'ARTICLE_STATUS_' . strtoupper( $module_params['status'] ) ) : ARTICLE_STATUS_APPROVED;
$sortOptions = array(
"last_modified_asc",
@@ -103,11 +99,7 @@ function data_articles($data, $params) { // No change in the parameters with Cly
"created_desc",
"random",
);
- if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) {
- $sort_mode = $module_params['sort_mode'];
- } else {
- $sort_mode = 'last_modified_desc';
- }
+ $sort_mode = ( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) ? $module_params['sort_mode'] : 'last_modified_desc';
$getHash = Array();
$getHash['status_id'] = $status_id;
@@ -134,7 +126,7 @@ function data_articles($data, $params) { // No change in the parameters with Cly
$display_result .= $gBitSmarty->fetch( 'bitpackage:articles/article_display.tpl' );
}
$display_result .= '</div>';
- $display_result = eregi_replace( "\n", "", $display_result );
+ $display_result = preg_replace( "/\\\\n/", '', $display_result );
break;
case 'list':
default:
diff --git a/list.php b/list.php
index 251a72d..c7e0d83 100644..100755
--- a/list.php
+++ b/list.php
@@ -9,7 +9,11 @@
* Initialization
*/
require_once '../kernel/includes/setup_inc.php';
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\Articles\BitArticle;
+use Bitweaver\Articles\BitArticleTopic;
+use Bitweaver\Articles\BitArticleType;
+use Bitweaver\KernelTools;
+
include_once( ARTICLES_PKG_INCLUDE_PATH.'article_filter_inc.php' );
// Is package installed and enabled
@@ -36,21 +40,21 @@ if( !empty( $_REQUEST['action'] ) ) {
if( isset( $_REQUEST["confirm"] ) ) {
if( $tmpArt->expunge() ) {
- bit_redirect( ARTICLES_PKG_URL.'list.php?status_id='.( !empty( $_REQUEST['status_id'] ) ? $_REQUEST['status_id'] : '' ) );
+ KernelTools::bit_redirect( ARTICLES_PKG_URL.'list.php?status_id='.( !empty( $_REQUEST['status_id'] ) ? $_REQUEST['status_id'] : '' ) );
} else {
$feedback['error'] = $tmpArt->mErrors;
}
}
- $gBitSystem->setBrowserTitle( tra('Confirm removal of'). ' ' .$tmpArt->mInfo['title'] );
+ $gBitSystem->setBrowserTitle( KernelTools::tra('Confirm removal of'). ' ' .$tmpArt->mInfo['title'] );
$formHash['remove'] = TRUE;
$formHash['action'] = 'remove';
$formHash['status_id'] = ( !empty( $_REQUEST['status_id'] ) ? $_REQUEST['status_id'] : '' );
$formHash['remove_article_id'] = $_REQUEST['remove_article_id'];
$msgHash = array(
- 'label' => tra('Remove Article'),
+ 'label' => KernelTools::tra('Remove Article'),
'confirm_item' => $tmpArt->mInfo['title'],
- 'warning' => tra('Remove the above article.'),
- 'error' => tra('This cannot be undone!'),
+ 'warning' => KernelTools::tra('Remove the above article.'),
+ 'error' => KernelTools::tra('This cannot be undone!'),
);
$gBitSystem->confirmDialog( $formHash, $msgHash );
}
@@ -79,4 +83,4 @@ $gBitSmarty->assign( 'listInfo', $_REQUEST['listInfo'] );
$gBitSmarty->assign( 'listpages', $listArticles );
// Display the template
-$gBitSystem->display( 'bitpackage:articles/list_articles.tpl', tra( "Articles" ), array( 'display_mode' => 'list' ));
+$gBitSystem->display( 'bitpackage:articles/list_articles.tpl', KernelTools::tra( "Articles" ), array( 'display_mode' => 'list' ));
diff --git a/list_topics.php b/list_topics.php
index 6c76b41..c7c4800 100644..100755
--- a/list_topics.php
+++ b/list_topics.php
@@ -9,8 +9,10 @@
* Initialization
*/
require_once '../kernel/includes/setup_inc.php';
+use Bitweaver\Articles\BitArticleTopic;
+use Bitweaver\Articles\BitArticle;
+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
@@ -20,4 +22,4 @@ $topics = BitArticleTopic::getTopicList();
$gBitSmarty->assign( 'topics', $topics );
-$gBitSystem->display( 'bitpackage:articles/list_topics.tpl', tra( 'List Topics' ) , array( 'display_mode' => 'list' ));
+$gBitSystem->display( 'bitpackage:articles/list_topics.tpl', KernelTools::tra( 'List Topics' ) , array( 'display_mode' => 'list' ));
diff --git a/modules/help_mod_articles.tpl b/modules/help_mod_articles.tpl
index 33af4b4..33af4b4 100644..100755
--- a/modules/help_mod_articles.tpl
+++ b/modules/help_mod_articles.tpl
diff --git a/modules/index.php b/modules/index.php
index 30a5490..30a5490 100644..100755
--- a/modules/index.php
+++ b/modules/index.php
diff --git a/modules/mod_articles.php b/modules/mod_articles.php
index 21123c4..4b43baa 100644..100755
--- a/modules/mod_articles.php
+++ b/modules/mod_articles.php
@@ -8,19 +8,16 @@
/**
* Initialization
*/
-include_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\Articles\BitArticle;
+
extract( $moduleParams );
$articles = new BitArticle();
$stati = array( 'pending', 'approved' );
-if( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) {
- $status_id = constant( 'ARTICLE_STATUS_'.strtoupper( $module_params['status'] ) );
-} else {
- $status_id = ARTICLE_STATUS_APPROVED;
-}
+$status_id = ( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) ? constant( 'ARTICLE_STATUS_' . strtoupper( $module_params['status'] ) ) : ARTICLE_STATUS_APPROVED;
-$sortOptions = array(
+$sortOptions = [
"last_modified_asc",
"last_modified_desc",
"created_asc",
@@ -29,12 +26,8 @@ $sortOptions = array(
"publish_date_asc",
"expire_date_desc",
"expire_date_asc",
-);
-if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) {
- $sort_mode = $module_params['sort_mode'];
-} else {
- $sort_mode = 'last_modified_desc';
-}
+];
+$sort_mode = ( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) ? $module_params['sort_mode'] : 'last_modified_desc';
$getHash['status_id'] = $status_id;
$getHash['sort_mode'] = $sort_mode;
@@ -44,13 +37,13 @@ $getHash['topic_id'] = !empty( $module_params['topic_id'] ) ? $module_param
$articlelist = $articles->getList( $getHash );
if( ( !empty( $module_params['topic_id'] ) || !empty( $module_params['topic_name'] ) ) && empty($moduleParams['title']) && !empty( $articles ) ) {
- $_template->tpl_vars['moduleTitle'] = new Smarty_variable( $articles[0]['topic_name'] );
+ $gBitSmarty->assign( 'moduleTitle', $articlelist[0]['topic_name'] );
} elseif( !empty($moduleParams['title']) ) {
- $_template->tpl_vars['moduleTitle'] = new Smarty_variable( $moduleParams['title'] );
+ $gBitSmarty->assign( 'moduleTitle', $moduleParams['title'] );
} else {
- $_template->tpl_vars['moduleTitle'] = new Smarty_variable( "Articles" );
+ $gBitSmarty->assign( 'moduleTitle', "Articles" );
}
-$_template->tpl_vars['params'] = new Smarty_variable( !empty( $moduleParams['params'] ) );
-$_template->tpl_vars['listtype'] = new Smarty_variable( ( isset($module_params['list_type']) && (strncasecmp($module_params['list_type'], 'u', 1) == 0) ) ? 'ul' : 'ol' );
-$_template->tpl_vars['modArticles'] = new Smarty_variable( $articlelist );
+$gBitSmarty->assign( 'params', !empty( $moduleParams['params'] ) );
+$gBitSmarty->assign( 'listtype', ( isset($module_params['list_type']) && (strncasecmp($module_params['list_type'], 'u', 1) == 0) ) ? 'ul' : 'ol' );
+$gBitSmarty->assign( 'modArticles', $articlelist );
diff --git a/modules/mod_articles.tpl b/modules/mod_articles.tpl
index a01016e..a01016e 100644..100755
--- a/modules/mod_articles.tpl
+++ b/modules/mod_articles.tpl
diff --git a/print.php b/print.php
index 96a4150..c524f9d 100644..100755
--- a/print.php
+++ b/print.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @version $Header$
* @package articles
@@ -9,11 +10,12 @@
* Initialization
*/
require_once '../kernel/includes/setup_inc.php';
+use Bitweaver\KernelTools;
include_once( ARTICLES_PKG_PATH . 'art_lib.php' );
if ( !isset( $_REQUEST["article_id"] ) ) {
- $gBitSmarty->assign( 'msg', tra( "No article indicated" ) );
+ $gBitSmarty->assign( 'msg', KernelTools::tra( "No article indicated" ) );
$gBitSmarty->display( "error.tpl" );
die;
@@ -26,14 +28,14 @@ if ( isset( $_REQUEST["article_id"] ) ) {
$article_data = $artlib->get_article( $_REQUEST["article_id"] );
if ( !$article_data ) {
- $gBitSmarty->assign( 'msg', tra( "Article not found" ) );
+ $gBitSmarty->assign( 'msg', KernelTools::tra( "Article not found" ) );
$gBitSmarty->display( "error.tpl" );
die;
}
if ( ( $article_data["publish_date"] > date( "U" ) ) && ( !$gBitUser->isAdmin() ) ) {
- $gBitSmarty->assign( 'msg', tra( "Article is not published yet" ) );
+ $gBitSmarty->assign( 'msg', KernelTools::tra( "Article is not published yet" ) );
$gBitSmarty->display( "error.tpl" );
die;
diff --git a/rankings.php b/rankings.php
index 19f1cb8..e1153bb 100644..100755
--- a/rankings.php
+++ b/rankings.php
@@ -10,50 +10,51 @@
*/
require_once '../kernel/includes/setup_inc.php';
-include_once( LIBERTY_PKG_CLASS_PATH.'LibertyContent.php' );
-include_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\KernelTools;
+use Bitweaver\Liberty\LibertyContent;
+use Bitweaver\Articles\BitArticle;
$gBitSystem->isPackageActive( 'articles' );
$gBitSystem->isFeatureActive( 'articles_rankings' );
$gBitSystem->verifyPermission( 'p_articles_read' );
-$rankingOptions = array(
- array(
- 'output' => tra( 'Most Often Viewed' ),
- 'value' => 'hits_desc'
- ),
- array(
- 'output' => tra( 'Most Recently Modified' ),
- 'value' => 'last_modified_desc'
- ),
- array(
- 'output' => tra( 'Most Active Authors' ),
- 'value' => 'top_authors'
- ),
-);
+$rankingOptions = [
+ [
+ 'output' => KernelTools::tra( 'Most Often Viewed' ),
+ 'value' => 'hits_desc',
+ ],
+ [
+ 'output' => KernelTools::tra( 'Most Recently Modified' ),
+ 'value' => 'last_modified_desc',
+ ],
+ [
+ 'output' => KernelTools::tra( 'Most Active Authors' ),
+ 'value' => 'top_authors',
+ ],
+];
$gBitSmarty->assign( 'rankingOptions', $rankingOptions );
if( !empty( $_REQUEST['sort_mode'] ) ) {
switch( $_REQUEST['sort_mode'] ) {
case 'last_modified_desc':
$gBitSmarty->assign( 'attribute', 'last_modified' );
- $_REQUEST['attribute'] = tra( 'Date of last modification' );
+ $_REQUEST['attribute'] = KernelTools::tra( 'Date of last modification' );
break;
case 'top_authors':
$gBitSmarty->assign( 'attribute', 'ag_hits' );
- $_REQUEST['attribute'] = tra( 'Hits to items by this Author' );
+ $_REQUEST['attribute'] = KernelTools::tra( 'Hits to items by this Author' );
break;
default:
$gBitSmarty->assign( 'attribute', 'hits' );
- $_REQUEST['attribute'] = tra( 'Hits' );
+ $_REQUEST['attribute'] = KernelTools::tra( 'Hits' );
break;
}
} else {
$gBitSmarty->assign( 'attribute', 'hits' );
- $_REQUEST['attribute'] = tra( 'Hits' );
+ $_REQUEST['attribute'] = KernelTools::tra( 'Hits' );
}
-$_REQUEST['title'] = tra( 'Article Rankings' );
+$_REQUEST['title'] = KernelTools::tra( 'Article Rankings' );
$_REQUEST['content_type_guid'] = BITARTICLE_CONTENT_TYPE_GUID;
$_REQUEST['max_records'] = !empty( $_REQUEST['max_records'] ) ? $_REQUEST['max_records'] : 10;
@@ -63,4 +64,4 @@ if( empty( $gContent ) ) {
$rankList = $gContent->getContentRanking( $_REQUEST );
$gBitSmarty->assign( 'rankList', $rankList );
-$gBitSystem->display( 'bitpackage:liberty/rankings.tpl', tra( "Article Rankings" ) , array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:liberty/rankings.tpl', KernelTools::tra( "Article Rankings" ) , [ 'display_mode' => 'display' ]);
diff --git a/read.php b/read.php
index 75e46c1..53f10f9 100644..100755
--- a/read.php
+++ b/read.php
@@ -10,19 +10,21 @@
*/
require_once '../kernel/includes/setup_inc.php';
-require_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+use Bitweaver\BitBase;
+use Bitweaver\KernelTools;
+use Bitweaver\Articles\BitArticleTopic;
$gBitSystem->verifyPackage( 'articles' );
if( !@BitBase::verifyId( $_REQUEST["article_id"] )) {
- $gBitSystem->fatalError( tra( "No article indicated" ));
+ $gBitSystem->fatalError( KernelTools::tra( "No article indicated" ));
}
include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_inc.php' );
// Check if we actually have some content
if( !$gContent->isValid() ) {
- $gBitSystem->fatalError( tra( 'Article cannot be found' ));
+ $gBitSystem->fatalError( KernelTools::tra( 'Article cannot be found' ));
}
$gContent->verifyViewPermission();
@@ -30,25 +32,25 @@ $gContent->verifyViewPermission();
// additionally we need to check if this article is a submission and see if user has perms to view it.
if( $gContent->getField( 'status_id' ) != ARTICLE_STATUS_APPROVED ) {
if( !( $gContent->hasUserPermission( 'p_articles_update_submission' ) || $gContent->hasUserPermission( 'p_articles_approve_submission' ))) {
- $gBitSystem->fatalError( tra( "Permission denied you cannot view this article" ));
+ $gBitSystem->fatalError( KernelTools::tra( "Permission denied you cannot view this article" ));
}
}
// we also need to check and see if the article is future dated - we will display it if the user can edit it otherwise we pretend it does not exist.
$timestamp = $gBitSystem->getUTCTime();
if ( ($gContent->mInfo['publish_date'] > $timestamp) && !$gContent->hasUpdatePermission() ){
- $gBitSystem->fatalError( tra( 'Article cannot be found' ));
+ $gBitSystem->fatalError( KernelTools::tra( 'Article cannot be found' ));
}
$gContent->addHit();
-$gBitSmarty->assignByRef( 'article', $gContent->mInfo );
+$gBitSmarty->assign( 'article', $gContent->mInfo );
// get all the services that want to display something on this page
$displayHash = array( 'perm_name' => 'p_articles_read' );
$gContent->invokeServices( 'content_display_function', $displayHash );
$topics = BitArticleTopic::getTopicList();
-$gBitSmarty->assignByRef( 'topics', $topics );
+$gBitSmarty->assign( 'topics', $topics );
// Comments engine!
if( @$gContent->mInfo['allow_comments'] == 'y' ) {
@@ -61,4 +63,4 @@ if( @$gContent->mInfo['allow_comments'] == 'y' ) {
}
// Display the Index Template
-$gBitSystem->display( 'bitpackage:articles/read_article.tpl', @$gContent->mInfo['title'] , array( 'display_mode' => 'display' ));
+$gBitSystem->display( 'bitpackage:articles/read_article.tpl', @$gContent->mInfo['title'] , [ 'display_mode' => 'display' ]);
diff --git a/templates/admin_articles.tpl b/templates/admin_articles.tpl
index 17f2c7d..17f2c7d 100644..100755
--- a/templates/admin_articles.tpl
+++ b/templates/admin_articles.tpl
diff --git a/templates/admin_topics.tpl b/templates/admin_topics.tpl
index 7f83a76..7f83a76 100644..100755
--- a/templates/admin_topics.tpl
+++ b/templates/admin_topics.tpl
diff --git a/templates/admin_types.tpl b/templates/admin_types.tpl
index 9cd9ee5..9cd9ee5 100644..100755
--- a/templates/admin_types.tpl
+++ b/templates/admin_types.tpl
diff --git a/templates/article_display.tpl b/templates/article_display.tpl
index ea05f21..ea05f21 100644..100755
--- a/templates/article_display.tpl
+++ b/templates/article_display.tpl
diff --git a/templates/article_filter_inc.tpl b/templates/article_filter_inc.tpl
index ce6b8ee..ce6b8ee 100644..100755
--- a/templates/article_filter_inc.tpl
+++ b/templates/article_filter_inc.tpl
diff --git a/templates/article_history.tpl b/templates/article_history.tpl
index d2c83ec..d2c83ec 100644..100755
--- a/templates/article_history.tpl
+++ b/templates/article_history.tpl
diff --git a/templates/articles_mini_search.tpl b/templates/articles_mini_search.tpl
index e3246c6..e3246c6 100644..100755
--- a/templates/articles_mini_search.tpl
+++ b/templates/articles_mini_search.tpl
diff --git a/templates/articles_nav.tpl b/templates/articles_nav.tpl
index 93a9b8e..93a9b8e 100644..100755
--- a/templates/articles_nav.tpl
+++ b/templates/articles_nav.tpl
diff --git a/templates/center_display_articles.php b/templates/center_display_articles.php
index 7c6c67d..f42cc7c 100644..100755
--- a/templates/center_display_articles.php
+++ b/templates/center_display_articles.php
@@ -1,15 +1,15 @@
<?php
-// $Header$
-global $gBitSmarty, $gBitSystem, $gQueryUserId, $moduleParams;
+use Bitweaver\Users\RoleUser;
+
+global $gBitSmarty, $gBitSystem, $gQueryUserId, $moduleParams, $gContent;
if ( !empty( $moduleParams ) ) {
extract( $moduleParams );
}
-include_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_inc.php' );
include_once( ARTICLES_PKG_INCLUDE_PATH.'article_filter_inc.php' );
-$listHash = array();
+$listHash = [];
if ( $gBitUser->hasPermission( 'p_articles_admin' ) ) {
$_REQUEST['status_id'] = !empty( $_REQUEST['status_id'] ) ? $_REQUEST['status_id'] : ARTICLE_STATUS_APPROVED;
@@ -17,17 +17,17 @@ if ( $gBitUser->hasPermission( 'p_articles_admin' ) ) {
$_REQUEST['topic_id'] = !empty( $_REQUEST['topic_id'] ) ? $_REQUEST['topic_id'] : NULL;
$_REQUEST['type_id'] = !empty( $_REQUEST['type_id'] ) ? $_REQUEST['type_id'] : NULL;
- $_template->tpl_vars['futures'] = new Smarty_variable( $gContent->getFutureList( $listHash ) );
+ $gBitSmarty->assign( 'futures', $gContent->getFutureList( $listHash ) );
} else {
$_REQUEST['status_id'] = ARTICLE_STATUS_APPROVED;
$_REQUEST['max_records'] = $gBitSystem->getConfig( 'articles_max_list' );
}
if ( !empty( $_REQUEST['topic'] ) ) {
- $_template->tpl_vars['topic'] = new Smarty_variable( $_REQUEST['topic'] );
+ $gBitSmarty->assign( 'topic', $_REQUEST['topic'] );
}
if ( !empty( $moduleParams )) {
- $listHash = array_merge( $_REQUEST, $moduleParams['module_params'] );
+ $listHash = [ ...$_REQUEST, ...$moduleParams['module_params'] ];
$listHash['max_records'] = $module_rows;
//$listHash['parse_data'] = TRUE;
//$listHash['load_comments'] = TRUE;
@@ -35,19 +35,19 @@ if ( !empty( $moduleParams )) {
$listHash = $_REQUEST;
}
-BitUser::userCollection( $_REQUEST, $listHash );
+RoleUser::userCollection( $_REQUEST, $listHash );
$articles = $gContent->getList( $listHash );
-$_template->tpl_vars['gContent'] = new Smarty_variable( $gContent );
-$_template->tpl_vars['articles'] = new Smarty_variable( $articles );
-$_template->tpl_vars['listInfo'] = new Smarty_variable( $listHash['listInfo'] );
+$gBitSmarty->assign( 'gContent', $gContent );
+$gBitSmarty->assign( 'articles', $articles );
+$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] );
// show only descriptions on listing page
-$_template->tpl_vars['showDescriptionsOnly'] = new Smarty_variable( TRUE );
+$gBitSmarty->assign( 'showDescriptionsOnly', TRUE );
// display submissions if we have the perm to approve them
if ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || ( $gBitSystem->isFeatureActive( 'articles_auto_approve' ) && $gBitUser->isRegistered() )) {
- $listHash = array( 'status_id' => ARTICLE_STATUS_PENDING );
+ $listHash = [ 'status_id' => ARTICLE_STATUS_PENDING ];
$submissions = $gContent->getList( $listHash );
- $_template->tpl_vars['submissions'] = new Smarty_variable( $submissions );
+ $gBitSmarty->assign( 'submissions', $submissions );
}
diff --git a/templates/center_display_articles.tpl b/templates/center_display_articles.tpl
index 795b27f..795b27f 100644..100755
--- a/templates/center_display_articles.tpl
+++ b/templates/center_display_articles.tpl
diff --git a/templates/center_list_articles.php b/templates/center_list_articles.php
index 7c6c67d..2300e13 100644..100755
--- a/templates/center_list_articles.php
+++ b/templates/center_list_articles.php
@@ -1,15 +1,16 @@
<?php
-// $Header$
-global $gBitSmarty, $gBitSystem, $gQueryUserId, $moduleParams;
+use Bitweaver\Users\RoleUser;
+
+global $gBitSmarty, $gBitSystem, $gQueryUserId, $moduleParams, $gContent;
if ( !empty( $moduleParams ) ) {
extract( $moduleParams );
}
-include_once( ARTICLES_PKG_CLASS_PATH.'BitArticle.php' );
+
include_once( ARTICLES_PKG_INCLUDE_PATH.'lookup_article_inc.php' );
include_once( ARTICLES_PKG_INCLUDE_PATH.'article_filter_inc.php' );
-$listHash = array();
+$listHash = [];
if ( $gBitUser->hasPermission( 'p_articles_admin' ) ) {
$_REQUEST['status_id'] = !empty( $_REQUEST['status_id'] ) ? $_REQUEST['status_id'] : ARTICLE_STATUS_APPROVED;
@@ -17,13 +18,13 @@ if ( $gBitUser->hasPermission( 'p_articles_admin' ) ) {
$_REQUEST['topic_id'] = !empty( $_REQUEST['topic_id'] ) ? $_REQUEST['topic_id'] : NULL;
$_REQUEST['type_id'] = !empty( $_REQUEST['type_id'] ) ? $_REQUEST['type_id'] : NULL;
- $_template->tpl_vars['futures'] = new Smarty_variable( $gContent->getFutureList( $listHash ) );
+ $gBitSmarty->assign( 'futures', $gContent->getFutureList( $listHash ) );
} else {
$_REQUEST['status_id'] = ARTICLE_STATUS_APPROVED;
$_REQUEST['max_records'] = $gBitSystem->getConfig( 'articles_max_list' );
}
if ( !empty( $_REQUEST['topic'] ) ) {
- $_template->tpl_vars['topic'] = new Smarty_variable( $_REQUEST['topic'] );
+ $gBitSmarty->assign( 'topic', $_REQUEST['topic'] );
}
if ( !empty( $moduleParams )) {
@@ -35,19 +36,19 @@ if ( !empty( $moduleParams )) {
$listHash = $_REQUEST;
}
-BitUser::userCollection( $_REQUEST, $listHash );
-
+RoleUser::userCollection( $_REQUEST, $listHash );
+$listHash['sort_mode'] = ' last_modified_desc';
$articles = $gContent->getList( $listHash );
-$_template->tpl_vars['gContent'] = new Smarty_variable( $gContent );
-$_template->tpl_vars['articles'] = new Smarty_variable( $articles );
-$_template->tpl_vars['listInfo'] = new Smarty_variable( $listHash['listInfo'] );
+$gBitSmarty->assign( 'gContent', $gContent );
+$gBitSmarty->assign( 'articles', $articles );
+$gBitSmarty->assign( 'listInfo', $listHash['listInfo'] );
// show only descriptions on listing page
-$_template->tpl_vars['showDescriptionsOnly'] = new Smarty_variable( TRUE );
+$gBitSmarty->assign( 'showDescriptionsOnly', TRUE );
// display submissions if we have the perm to approve them
if ( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || ( $gBitSystem->isFeatureActive( 'articles_auto_approve' ) && $gBitUser->isRegistered() )) {
$listHash = array( 'status_id' => ARTICLE_STATUS_PENDING );
$submissions = $gContent->getList( $listHash );
- $_template->tpl_vars['submissions'] = new Smarty_variable( $submissions );
+ $gBitSmarty->assign( 'submissions', $submissions );
}
diff --git a/templates/center_list_articles.tpl b/templates/center_list_articles.tpl
index 1531e1b..1531e1b 100644..100755
--- a/templates/center_list_articles.tpl
+++ b/templates/center_list_articles.tpl
diff --git a/templates/edit_article.tpl b/templates/edit_article.tpl
index eb22437..b64caaf 100644..100755
--- a/templates/edit_article.tpl
+++ b/templates/edit_article.tpl
@@ -1,4 +1,4 @@
-<script type="text/javascript">//<![CDATA[
+<script>//<![CDATA[
function charCounter( textareaId, counterId, maxLimit ) {ldelim}
document.getElementById( counterId ).value = maxLimit - document.getElementById( textareaId ).value.length;
{rdelim}
diff --git a/templates/edit_topic.tpl b/templates/edit_topic.tpl
index 08e6b6c..08e6b6c 100644..100755
--- a/templates/edit_topic.tpl
+++ b/templates/edit_topic.tpl
diff --git a/templates/html_head_inc.tpl b/templates/html_head_inc.tpl
index 76826a7..76826a7 100644..100755
--- a/templates/html_head_inc.tpl
+++ b/templates/html_head_inc.tpl
diff --git a/templates/index.php b/templates/index.php
index 30a5490..30a5490 100644..100755
--- a/templates/index.php
+++ b/templates/index.php
diff --git a/templates/list_articles.tpl b/templates/list_articles.tpl
index 24289da..24289da 100644..100755
--- a/templates/list_articles.tpl
+++ b/templates/list_articles.tpl
diff --git a/templates/list_topics.tpl b/templates/list_topics.tpl
index 83132a0..83132a0 100644..100755
--- a/templates/list_topics.tpl
+++ b/templates/list_topics.tpl
diff --git a/templates/menu_articles.tpl b/templates/menu_articles.tpl
index e14b30b..e14b30b 100644..100755
--- a/templates/menu_articles.tpl
+++ b/templates/menu_articles.tpl
diff --git a/templates/menu_articles_admin.tpl b/templates/menu_articles_admin.tpl
index 9a3f767..9a3f767 100644..100755
--- a/templates/menu_articles_admin.tpl
+++ b/templates/menu_articles_admin.tpl
diff --git a/templates/preview_article.tpl b/templates/preview_article.tpl
index 48a1272..48a1272 100644..100755
--- a/templates/preview_article.tpl
+++ b/templates/preview_article.tpl
diff --git a/templates/print_article.tpl b/templates/print_article.tpl
index 68e7fb0..68e7fb0 100644..100755
--- a/templates/print_article.tpl
+++ b/templates/print_article.tpl
diff --git a/templates/read_article.tpl b/templates/read_article.tpl
index bc3060f..bc3060f 100644..100755
--- a/templates/read_article.tpl
+++ b/templates/read_article.tpl
diff --git a/templates/submission_notification.tpl b/templates/submission_notification.tpl
index 18c2de1..18c2de1 100644..100755
--- a/templates/submission_notification.tpl
+++ b/templates/submission_notification.tpl
diff --git a/test/TestTikiArticle.php b/test/TestTikiArticle.php
index 062e9e5..89eb857 100644..100755
--- a/test/TestTikiArticle.php
+++ b/test/TestTikiArticle.php
@@ -1,6 +1,6 @@
<?php
require_once '../../kernel/includes/setup_inc.php';
-require_once(ARTICLES_PKG_CLASS_PATH.'BitArticle.php');
+use Bitweaver\Articles\BitArticle;
class TestBitArticle extends Test
{
diff --git a/test/index.php b/test/index.php
index 8abfcb8..8abfcb8 100644..100755
--- a/test/index.php
+++ b/test/index.php