summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2025-08-28 17:09:37 +0100
committerlsces <lester@lsces.co.uk>2025-08-28 17:09:37 +0100
commit90d97e75a775e7a9705e9abe119bed304dd476fa (patch)
treeccf671ec4264b19b109eaf8daedc50a9245a2a1e
parent1d7281a3e40d9730f2b408dc58ae7bb5cd0acb21 (diff)
downloadblogs-90d97e75a775e7a9705e9abe119bed304dd476fa.tar.gz
blogs-90d97e75a775e7a9705e9abe119bed304dd476fa.tar.bz2
blogs-90d97e75a775e7a9705e9abe119bed304dd476fa.zip
Admin code updated to PHP8.4 and namespace
-rwxr-xr-x[-rw-r--r--]admin/admin_blogs_inc.php86
-rwxr-xr-x[-rw-r--r--]admin/index.php2
-rwxr-xr-x[-rw-r--r--]admin/pump_blogs_inc.php69
-rwxr-xr-x[-rw-r--r--]admin/schema_inc.php102
-rwxr-xr-x[-rw-r--r--]admin/wp-migrate.php63
5 files changed, 157 insertions, 165 deletions
diff --git a/admin/admin_blogs_inc.php b/admin/admin_blogs_inc.php
index 0a5f0dc..df116c6 100644..100755
--- a/admin/admin_blogs_inc.php
+++ b/admin/admin_blogs_inc.php
@@ -1,87 +1,93 @@
<?php
// $Header$
+/**
+ * required setup
+ */
+namespace Bitweaver\Blogs;
+use Bitweaver\BitBase;
+
// get a list of blogs for the selection of the home blog
-require_once( BLOGS_PKG_CLASS_PATH.'BitBlog.php' );
+
$blog = new BitBlog();
$listHash['sort_mode'] = 'created_desc';
$blogList = $blog->getList( $listHash );
-$gBitSmarty->assignByRef( 'blogList', $blogList );
+$gBitSmarty->assign( 'blogList', $blogList );
if( !empty( $_REQUEST["set_blog_home"] )) {
- $blog_home = @BitBase::verifyId( $_REQUEST['blog_home'] ) ? $_REQUEST['blog_home'] : NULL;
+ $blog_home = BitBase::verifyId( $_REQUEST['blog_home'] ?? 0 ) ? $_REQUEST['blog_home'] : null;
$gBitSystem->storeConfig( "blog_home", $blog_home, BLOGS_PKG_NAME );
$gBitSmarty->assign( 'blog_home', $blog_home );
}
-$formBlogLists = array(
- "blog_list_title" => array(
+$formBlogLists = [
+ "blog_list_title" => [
'label' => 'Title',
- ),
- "blog_list_description" => array(
+ ],
+ "blog_list_description" => [
'label' => 'Description',
- ),
- "blog_list_created" => array(
+ ],
+ "blog_list_created" => [
'label' => 'Creation date',
- ),
- "blog_list_lastmodif" => array(
+ ],
+ "blog_list_lastmodif" => [
'label' => 'Last modification time',
- ),
- "blog_list_user" => array(
+ ],
+ "blog_list_user" => [
'label' => 'Creator',
'note' => 'The creator of a particular blog.',
- ),
- "blog_list_posts" => array(
+ ],
+ "blog_list_posts" => [
'label' => 'Posts',
'note' => 'Number of posts submitted to any given blog.',
- ),
- "blog_list_visits" => array(
+ ],
+ "blog_list_visits" => [
'label' => 'Visits',
'note' => 'Number of times a given blog has been visited.',
- ),
+ ],
/** @TODO: Add back once activity is implemented
- "blog_list_activity" => array(
+ "blog_list_activity" => [
'label' => 'Activity',
'note' => 'This number is an indication of how active a given blog is. The number is calculated based on god knows what...',
- ),
+ ],
**/
-);
+];
$gBitSmarty->assign( 'formBlogLists',$formBlogLists );
-$formBlogFeatures = array(
- "blog_rankings" => array(
+$formBlogFeatures = [
+ "blog_rankings" => [
'label' => 'Rankings',
'note' => 'Enable the use of rankings based on page hits.',
- ),
- "blog_posts_comments" => array(
+ ],
+ "blog_posts_comments" => [
'label' => 'Blog Post Comments',
'note' => 'Allow the addition of comments to blog posts.',
- ),
- "blog_posts_autosplit" => array(
+ ],
+ "blog_posts_autosplit" => [
'label' => 'Use 2 Text Fields To Auto Split Blog Posts',
'note' => 'Display two text fields when editing a post, for intro and read more sections. Disabling will display one text field and requires use of ...split... to create a read more section',
- ),
- "blog_ajax_more" => array(
+ ],
+ "blog_ajax_more" => [
'label' => 'Ajax Read More',
'note' => 'Ajax the "read more" text inline into the short description lists of posts.',
- ),
- "blog_show_image" => array(
+ ],
+ "blog_show_image" => [
'label' => 'Auto Display Primary Attachment',
'note' => 'Blog posts can automatically display any attachment, typically an image, that is marked as the "Primary Attachment" during editing. This is especially useful for automatically inserting a photograph into a post.',
- ),
- "blog_hide_empty_usr_list" => array(
+ ],
+ "blog_hide_empty_usr_list" => [
'label' => 'Hide empty blog message on user pages',
'note' => 'Enable to hide the "No Records Found" on user\'s blog rolls',
- ),
-);
+ ],
+];
$gBitSmarty->assign( 'formBlogFeatures',$formBlogFeatures );
-$formBlogInputs = array(
- "blog_top_post_count" => array(
+$formBlogInputs = [
+ "blog_top_post_count" => [
'label' => 'Top Post Count',
'note' => 'How many posts per blog in the rankings should be shown.',
- ),
-);
+ ],
+];
$gBitSmarty->assign( 'formBlogInputs', $formBlogInputs );
$processForm = set_tab();
@@ -103,5 +109,3 @@ if( $processForm ) {
$gBitSmarty->assign('blog_list_order', $_REQUEST["blog_list_order"]);
$gBitSmarty->assign('blog_list_user_as', $_REQUEST['blog_list_user_as']);
}
-
-?>
diff --git a/admin/index.php b/admin/index.php
index 3e305fe..1e6de35 100644..100755
--- a/admin/index.php
+++ b/admin/index.php
@@ -2,5 +2,3 @@
// This is not a package.
header ("location: ../index.php");
-
-?> \ No newline at end of file
diff --git a/admin/pump_blogs_inc.php b/admin/pump_blogs_inc.php
index caf0ff6..f615c52 100644..100755
--- a/admin/pump_blogs_inc.php
+++ b/admin/pump_blogs_inc.php
@@ -9,58 +9,58 @@
/**
* required setup
*/
-include_once( BLOGS_PKG_CLASS_PATH.'BitBlog.php' );
+namespace Bitweaver\Blogs;
-$pageHash = array(
- 'fSavePage' => TRUE,
- 'format_guid' => 'tikiwiki',
- 'title' => 'bitweaver Blog',
- 'edit' => 'Sample Blog added during the installation process',
- 'use_title' => 'y',
- 'max_posts' => '10',
- 'use_title' => 'on',
- 'use_find' => 'on',
- 'allow_comments' => 'on',
-);
+$pageHash = [
+ 'fSavePage' => true,
+ 'format_guid' => 'tikiwiki',
+ 'title' => 'bitweaver Blog',
+ 'edit' => 'Sample Blog added during the installation process',
+ 'use_title' => 'y',
+ 'max_posts' => '10',
+ 'use_find' => 'on',
+ 'allow_comments' => 'on',
+];
$gBlog = new BitBlog();
if( $gBlog->store( $pageHash ) ) {
- $blogPostHash = array(
- array(
- 'fSavePage' => TRUE,
+ $blogPostHash = [
+ [
+ 'fSavePage' => true,
'format_guid' => 'tikiwiki',
- 'blog_content_id' => array($gBlog->mContentId),
- 'trackback' => NULL,
+ 'blog_content_id' => [ $gBlog->mContentId ],
+ 'trackback' => null,
'title' => 'Lorem Ipsum',
'edit' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum molestie lectus quis elit. Suspendisse scelerisque augue vitae ipsum. Maecenas quis enim. Suspendisse at turpis sed sem ullamcorper aliquam. Aliquam pede ligula, auctor vitae, interdum eget, aliquam vitae, magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam varius feugiat neque. Pellentesque varius. Fusce a mi in nulla porta aliquam. Morbi scelerisque, turpis quis sodales blandit, libero lorem faucibus dui, sit amet lacinia sem pede in quam. Pellentesque tempor suscipit sem. Nam sed augue.
- Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam.
+ Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam.
- Donec nec velit. Mauris scelerisque vestibulum ante. Nulla congue commodo lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aenean posuere, magna sit amet pharetra consectetuer, erat sapien ultricies elit, sit amet sollicitudin sem nibh vitae erat. Proin commodo feugiat nunc. Proin in eros. Fusce nec ante. Nulla convallis mi quis arcu. Duis quam. Cras arcu sem, posuere ut, sodales sit amet, blandit eu, orci. Sed tincidunt egestas est. Curabitur tempus, ipsum ut blandit accumsan, odio tellus egestas ipsum, sit amet cursus lacus velit et est. Nulla at sem. Aliquam quam purus, bibendum ut, tristique sollicitudin, interdum eget, ante. Nulla a ligula. Mauris scelerisque sem a odio. Quisque a nunc sed risus eleifend rutrum. Maecenas vitae lacus.
- '),
- array(
- 'fSavePage' => TRUE,
+ Donec nec velit. Mauris scelerisque vestibulum ante. Nulla congue commodo lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aenean posuere, magna sit amet pharetra consectetuer, erat sapien ultricies elit, sit amet sollicitudin sem nibh vitae erat. Proin commodo feugiat nunc. Proin in eros. Fusce nec ante. Nulla convallis mi quis arcu. Duis quam. Cras arcu sem, posuere ut, sodales sit amet, blandit eu, orci. Sed tincidunt egestas est. Curabitur tempus, ipsum ut blandit accumsan, odio tellus egestas ipsum, sit amet cursus lacus velit et est. Nulla at sem. Aliquam quam purus, bibendum ut, tristique sollicitudin, interdum eget, ante. Nulla a ligula. Mauris scelerisque sem a odio. Quisque a nunc sed risus eleifend rutrum. Maecenas vitae lacus.
+ '],
+ [
+ 'fSavePage' => true,
'format_guid' => 'tikiwiki',
- 'blog_content_id' => array($gBlog->mContentId),
- 'trackback' => NULL,
+ 'blog_content_id' => [ $gBlog->mContentId ],
+ 'trackback' => null,
'title' => 'Another Blog',
'edit' => 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum molestie lectus quis elit. Suspendisse scelerisque augue vitae ipsum. Maecenas quis enim. Suspendisse at turpis sed sem ullamcorper aliquam. Aliquam pede ligula, auctor vitae, interdum eget, aliquam vitae, magna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam varius feugiat neque. Pellentesque varius. Fusce a mi in nulla porta aliquam. Morbi scelerisque, turpis quis sodales blandit, libero lorem faucibus dui, sit amet lacinia sem pede in quam. Pellentesque tempor suscipit sem. Nam sed augue.
- Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam.
- '),
- array(
- 'fSavePage' => TRUE,
+ Nulla blandit. Vestibulum tempor ullamcorper nulla. Pellentesque varius lectus nec urna. Proin volutpat pede in eros. Mauris sit amet pede in neque nonummy congue. Ut vitae felis. Nunc lacinia. Fusce placerat faucibus orci. Ut vel libero et nisl hendrerit pretium. Sed quis quam id augue porta tempus. Nullam ante risus, blandit sed, eleifend eget, imperdiet a, sapien. Vestibulum libero. Phasellus viverra nonummy dui. In ultrices. Pellentesque imperdiet eros vel urna. Maecenas fringilla rutrum sem. Nullam lacinia, ipsum ut euismod scelerisque, mi dolor faucibus eros, in semper magna lorem non risus. Cras nec elit. Etiam egestas. Praesent placerat diam.
+ '],
+ [
+ 'fSavePage' => true,
'format_guid' => 'tikiwiki',
- 'blog_content_id' => array($gBlog->mContentId),
- 'trackback' => NULL,
+ 'blog_content_id' => [$gBlog->mContentId ],
+ 'trackback' => null,
'title' => 'Welcome',
'edit' => 'This is the blogs package of bitweaver. A blog is short for __web log__ and is basically a journal that is available on the web. The activity of updating a blog is "blogging" and someone who keeps a blog is a "blogger." Blogs are typically updated daily using software that allows people with little or no technical background to update and maintain the blog. Postings on a blog are almost always arranged in cronological order with the most recent additions featured most prominantly.
- If you have added the __Package Wiki__ to your isntallation and added the wiki sample data, you will notice that it is possible to link to those pages using simple wiki words such as bitweaverGlossary.
- '),
- );
+ If you have added the __Package Wiki__ to your isntallation and added the wiki sample data, you will notice that it is possible to link to those pages using simple wiki words such as bitweaverGlossary.
+ '],
+ ];
+
foreach( $blogPostHash as $blogPost ) {
- $newPost = new BitBlogPost( NULL );
+ $newPost = new BitBlogPost( null );
if( $newPost->store( $blogPost ) ) {
$pumpedData['Blog'][] = $blogPost['title'];
} else {
@@ -69,4 +69,3 @@ if( $gBlog->store( $pageHash ) ) {
}
}
}
-?>
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index dd14aba..21699b4 100644..100755
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -1,6 +1,6 @@
<?php
-$tables = array(
+$tables = [
'blog_posts' => "
post_id I4 PRIMARY,
@@ -36,7 +36,7 @@ $tables = array(
, CONSTRAINT `blogs_posts_map_blog_ref` FOREIGN KEY (`blog_content_id`) REFERENCES `".BIT_DB_PREFIX."liberty_content` (`content_id`)'
",
-);
+];
global $gBitInstaller;
@@ -44,61 +44,61 @@ foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( BLOGS_PKG_NAME, $tableName, $tables[$tableName] );
}
-$gBitInstaller->registerPackageInfo( BLOGS_PKG_NAME, array(
+$gBitInstaller->registerPackageInfo( BLOGS_PKG_NAME, [
'description' => "A Blog is a web based journal or diary.",
'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
-) );
+] );
// ### Indexes
-$indices = array (
- 'blog_posts_post_id_idx' => array( 'table' => 'blog_posts', 'cols' => 'post_id', 'opts' => NULL ),
- 'blogs_content_id_idx' => array( 'table' => 'blogs', 'cols' => 'content_id', 'opts' => array( 'UNIQUE' ) ),
- 'blog_posts_content_id_idx' => array( 'table' => 'blog_posts', 'cols' => 'content_id', 'opts' => array( 'UNIQUE' ) ),
-);
+$indices = [
+ 'blog_posts_post_id_idx' => [ 'table' => 'blog_posts', 'cols' => 'post_id', 'opts' => null ],
+ 'blogs_content_id_idx' => [ 'table' => 'blogs', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ],
+ 'blog_posts_content_id_idx' => [ 'table' => 'blog_posts', 'cols' => 'content_id', 'opts' => [ 'UNIQUE' ] ],
+];
/** @TODO - SPIDERR - following seems to cause time _decrease_ cause bigint on postgres. need more investigation
- * 'blog_posts_created_idx' => array( 'table' => 'blog_posts', 'cols' => 'created', 'opts' => NULL ),
+ * 'blog_posts_created_idx' => [ 'table' => 'blog_posts', 'cols' => 'created', 'opts' => null ],
**/
$gBitInstaller->registerSchemaIndexes( BLOGS_PKG_NAME, $indices );
// ### Sequences
-$sequences = array (
- 'blogs_blog_id_seq' => array( 'start' => 1 ),
- 'blog_posts_post_id_seq' => array( 'start' => 1 )
-);
+$sequences = [
+ 'blogs_blog_id_seq' => [ 'start' => 1 ],
+ 'blog_posts_post_id_seq' => [ 'start' => 1 ]
+];
$gBitInstaller->registerSchemaSequences( BLOGS_PKG_NAME, $sequences );
// ### Default UserPermissions
-$gBitInstaller->registerUserPermissions( BLOGS_PKG_NAME, array(
- array('p_blogs_create', 'Can create a blog', 'registered', BLOGS_PKG_NAME),
- array('p_blogs_create_is_public', 'Can create a public blog', 'editors', BLOGS_PKG_NAME),
- array('p_blogs_post', 'Can create a blog post', 'registered', BLOGS_PKG_NAME),
- array('p_blogs_update', 'Can update blogs and blog posts', 'editors', BLOGS_PKG_NAME),
- array('p_blogs_send_post', 'Can email a blog post', 'registered', BLOGS_PKG_NAME),
- array('p_blogs_admin', 'Can admin blogs', 'editors', BLOGS_PKG_NAME),
- array('p_blogs_view', 'Can read blogs', 'basic', BLOGS_PKG_NAME),
- array('p_blog_posts_read_future', 'Can view future dated posts', 'editors', BLOGS_PKG_NAME),
- array('p_blog_posts_read_expired', 'Can view expired posts', 'editors', BLOGS_PKG_NAME)
-) );
+$gBitInstaller->registerUserPermissions( BLOGS_PKG_NAME, [
+ [ 'p_blogs_create', 'Can create a blog', 'registered', BLOGS_PKG_NAME ],
+ [ 'p_blogs_create_is_public', 'Can create a public blog', 'editors', BLOGS_PKG_NAME ],
+ [ 'p_blogs_post', 'Can create a blog post', 'registered', BLOGS_PKG_NAME ],
+ [ 'p_blogs_update', 'Can update blogs and blog posts', 'editors', BLOGS_PKG_NAME ],
+ [ 'p_blogs_send_post', 'Can email a blog post', 'registered', BLOGS_PKG_NAME ],
+ [ 'p_blogs_admin', 'Can admin blogs', 'editors', BLOGS_PKG_NAME ],
+ [ 'p_blogs_view', 'Can read blogs', 'basic', BLOGS_PKG_NAME ],
+ [ 'p_blog_posts_read_future', 'Can view future dated posts', 'editors', BLOGS_PKG_NAME ],
+ [ 'p_blog_posts_read_expired', 'Can view expired posts', 'editors', BLOGS_PKG_NAME ]
+] );
// ### Default Preferences
-$gBitInstaller->registerPreferences( BLOGS_PKG_NAME, array(
- array( BLOGS_PKG_NAME, 'blog_list_activity','y'),
- array( BLOGS_PKG_NAME, 'blog_list_created','y'),
- array( BLOGS_PKG_NAME, 'blog_list_description','y'),
- array( BLOGS_PKG_NAME, 'blog_list_lastmodif','y'),
- array( BLOGS_PKG_NAME, 'blog_list_order','created_desc'),
- array( BLOGS_PKG_NAME, 'blog_list_posts','y'),
- array( BLOGS_PKG_NAME, 'blog_list_title','y'),
- array( BLOGS_PKG_NAME, 'blog_list_user','n'),
- array( BLOGS_PKG_NAME, 'blog_list_visits','y'),
- array( BLOGS_PKG_NAME, 'blog_categ','n'),
- array( BLOGS_PKG_NAME, 'blog_parent_categ',0),
- array( BLOGS_PKG_NAME, 'blog_posts_comments','n'),
- array( BLOGS_PKG_NAME, 'blog_rankings','y'),
- array( BLOGS_PKG_NAME, 'blog_list_user_as', 'text'),
- array( BLOGS_PKG_NAME, 'blog_posts_description_length', '500'),
- array( BLOGS_PKG_NAME, 'blog_posts_max_list','10'),
-) );
+$gBitInstaller->registerPreferences( BLOGS_PKG_NAME, [
+ [ BLOGS_PKG_NAME, 'blog_list_activity','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_created','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_description','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_lastmodif','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_order','created_desc'],
+ [ BLOGS_PKG_NAME, 'blog_list_posts','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_title','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_user','n'],
+ [ BLOGS_PKG_NAME, 'blog_list_visits','y'],
+ [ BLOGS_PKG_NAME, 'blog_categ','n'],
+ [ BLOGS_PKG_NAME, 'blog_parent_categ',0],
+ [ BLOGS_PKG_NAME, 'blog_posts_comments','n'],
+ [ BLOGS_PKG_NAME, 'blog_rankings','y'],
+ [ BLOGS_PKG_NAME, 'blog_list_user_as', 'text'],
+ [ BLOGS_PKG_NAME, 'blog_posts_description_length', '500'],
+ [ BLOGS_PKG_NAME, 'blog_posts_max_list','10'],
+] );
// ### User Preferences Set In This Package
/** These are mentioned here for reference to understand how the package works
@@ -115,19 +115,19 @@ $gBitInstaller->registerPreferences( BLOGS_PKG_NAME, array(
**/
if(defined('RSS_PKG_NAME')) {
- $gBitInstaller->registerPreferences( BLOGS_PKG_NAME, array(
- array( RSS_PKG_NAME, BLOGS_PKG_NAME.'_rss', 'y'),
- ));
+ $gBitInstaller->registerPreferences( BLOGS_PKG_NAME, [
+ [ RSS_PKG_NAME, BLOGS_PKG_NAME.'_rss', 'y' ],
+ ]);
}
// ### Register content types
-$gBitInstaller->registerContentObjects( BLOGS_PKG_NAME, array(
+$gBitInstaller->registerContentObjects( BLOGS_PKG_NAME, [
'BitBlog'=>BLOGS_PKG_CLASS_PATH.'BitBlog.php',
'BitBlogPost'=>BLOGS_PKG_CLASS_PATH.'BitBlogPost.php'
-));
+] );
// Requirements
-$gBitInstaller->registerRequirements( BLOGS_PKG_NAME, array(
- 'liberty' => array( 'min' => '2.1.4' ),
-));
+$gBitInstaller->registerRequirements( BLOGS_PKG_NAME, [
+ 'liberty' => [ 'min' => '5.0.0' ],
+] );
diff --git a/admin/wp-migrate.php b/admin/wp-migrate.php
index 9d0dd58..8aa2ae7 100644..100755
--- a/admin/wp-migrate.php
+++ b/admin/wp-migrate.php
@@ -17,16 +17,15 @@
* You need to have liberty_allow_change_owner on for post ownership to work right. Otherwise all posts will be owned by admin.
*/
-require_once( '../../kernel/includes/setup_inc.php' );
-
-//require_once(USERS_PKG_PATH.'RoleUser.php');
-require_once(BLOGS_PKG_CLASS_PATH.'BitBlog.php');
-require_once(BLOGS_PKG_CLASS_PATH.'BitBlogPost.php');
-require_once(LIBERTY_PKG_CLASS_PATH.'LibertyComment.php');
+namespace Bitweaver\Blogs;
+require_once '../../kernel/includes/setup_inc.php';
+use Bitweaver\KernelTools;
+use Bitweaver\Liberty\LibertyComment;
+use Bitweaver\Users\RoleUser;
$gBitSystem->verifyPermission( 'p_admin' );
-$_SESSION['captcha_verified'] = TRUE;
+$_SESSION['captcha_verified'] = true;
// To Run from the command line uncomment and set the right value here.
# $_REQUEST['wp_config'] = "/path/to/wordpress/";
@@ -35,16 +34,16 @@ if (isset($_REQUEST['wp_config'])) {
$config = $_REQUEST['wp_config']."/wp-config.php";
$format = $_REQUEST['wp_config']."/wp-includes/functions-formatting.php";
if (file_exists($config)) {
- require_once($config);
- require_once($format);
+ require_once $config;
+ require_once $format;
migrate_wp();
} else {
- $errors['error'] = tra("The config file and format-function file do not exist.");
+ $errors['error'] = KernelTools::tra("The config file and format-function file do not exist.");
$gBitSmarty->assign('errors', $errors);
}
$gBitSmarty->assign('wp_config', $_REQUEST['wp_config']);
}
-$gBitSystem->display("bitpackage:blogs/wp-migrate.tpl", tra("WordPress Migrate"), array( 'display_mode' => 'admin' ));
+$gBitSystem->display("bitpackage:blogs/wp-migrate.tpl", KernelTools::tra("WordPress Migrate"), array( 'display_mode' => 'admin' ));
die;
function migrate_wp() {
@@ -65,7 +64,7 @@ function migrate_wp() {
migrate_wp_comments();
$gBitSystem->storeConfig('blogs_wp_migration', 'y', 'blogs');
- $errors['success'] = tra("Your migration is complete.");
+ $errors['success'] = KernelTools::tra("Your migration is complete.");
$gBitSmarty->assign('errorMap', $gErrorMap);
$gBitSmarty->assign('errors', $errors);
}
@@ -81,10 +80,10 @@ function setup_migration() {
'blogs_wp_comments' => "wp_id INT PRIMARY, comment_id INT NOTNULL",
);
$gBitSystem->mDb->createTables($tables);
- $gUserMap = array();
- $gBlogMap = array();
- $gPostMap = array();
- $gCommentMap = array();
+ $gUserMap = [];
+ $gBlogMap = [];
+ $gPostMap = [];
+ $gCommentMap = [];
$gMaxUser = -1;
$gMaxBlog = -1;
$gMaxPost = -1;
@@ -118,12 +117,12 @@ function migrate_wp_users() {
// Get everybody with a post
$query = "select distinct(u.ID) from ".$wpdb->table_prefix."wp_users u INNER JOIN ".$wpdb->table_prefix."wp_comments c ON (u.ID = c.user_id) WHERE u.ID != 1";
- $post_users = $wpdb->get_results($query, ARRAY_A);
+ $post_users = $wpdb->get_results($query, null);
// Get everybody with a comment
$query = "select distinct(u.ID) from ". $wpdb->table_prefix."wp_users u INNER JOIN ".$wpdb->table_prefix."wp_posts p ON (u.ID = p.post_author) WHERE u.ID != 1";
- $comment_users = $wpdb->get_results($query, ARRAY_A);
+ $comment_users = $wpdb->get_results($query, null);
- $users = array();
+ $users = [];
foreach ($post_users as $key => $data) {
$users[$data['ID']] = $data['ID'];
}
@@ -139,8 +138,8 @@ function migrate_wp_users() {
// vd($user_data);
if (!empty($user_data)) {
foreach($user_data as $data) {
- $bu = new BitUser();
- $pParamHash = array();
+ $bu = new RoleUser();
+ $pParamHash = [];
// Strip out characters that bitweaver doesn't support in logins.
preg_match_all( '/[A-Za-z0-9_-]*/', $data->login, $matches);
// vd($matches);
@@ -185,7 +184,7 @@ function migrate_wp_categories() {
foreach ($blog_data as $blog) {
// vd($blog);
$b = new BitBlog();
- $pParamHash = array();
+ $pParamHash = [];
$pParamHash['title'] = $blog->cat_name;
$pParamHash['use_title'] = 'y';
@@ -224,14 +223,11 @@ function migrate_wp_posts() {
if (!empty($posts)) {
foreach ($posts as $post) {
- $pParamHash = array();
+ $pParamHash = [];
$pParamHash['data'] = wptexturize(convert_chars(wpautop($post->post_content)));
$pParamHash['title'] = $post->post_title;
- if ($post->post_status == 'draft') {
- $pParamHash['content_status'] = -5;
- } else {
- $pParamHash['content_status'] = 50;
- }
+ $pParamHash['content_status'] = $post->post_status == 'draft' ? -5 : 50;
+
$pParamHash['publish_date'] = $gBitSystem->mServerTimestamp->getTimestampFromIso($post->post_date_gmt);
$pParamHash['last_modified'] = $gBitSystem->mServerTimestamp->getTimestampFromIso($post->post_modified_gmt);
if (empty($gUserMap[$post->post_author])) {
@@ -307,7 +303,7 @@ function migrate_wp_comments() {
if (!empty($comments)) {
foreach ($comments as $comment) {
// vd($comment);
- $pParamHash = array();
+ $pParamHash = [];
$pParamHash['edit'] = wptexturize(convert_chars(wpautop($comment->comment_content)));
if (empty($comment->user_id)) {
$pParamHash['annon_name'] = $comment->comment_author;
@@ -320,11 +316,8 @@ function migrate_wp_comments() {
$pParamHash['current_owner_id'] = -1;
}
}
- if ($comment->comment_approved) {
- $pParamHash['content_status'] = 50;
- } else {
- $pParamHash['content_status'] = -1;
- }
+ $pParamHash['content_status'] = $comment->comment_approved ? 50 : -1;
+
$pParamHash['last_modified'] = $gBitSystem->mServerTimestamp->getTimestampFromIso($comment->comment_date_gmt);
if (!empty($gPostMap[$comment->comment_post_ID])) {
$pParamHash['root_id'] = $gPostMap[$comment->comment_post_ID];
@@ -352,5 +345,3 @@ function migrate_wp_comments() {
}
}
}
-
-?>