Kaynağa Gözat

Home: the create-post block shows only its form (#5835)

* Home: the create-post block shows only its form

The "Add new..." block on the home page drew its own title, background and
padding around the create-post form, a box inside a box. It now uses the
content-only design box, so the form sits in the feed like a post: on the
web site and in the NEO apps, at every screen size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test the create-post block default in the install SQL, not the installed site

An admin may pick another design box in Studio, and the migration keeps that
choice, so the installed site is no place to check the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 1 hafta önce
ebeveyn
işleme
464cce9c7e

+ 1 - 1
install/sql/system.sql

@@ -6347,7 +6347,7 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `
 ('sys_home', 1, 'system', '', '_sys_page_block_title_homepage_menu', 13, 0, 0, 2147483647, 'menu', 'sys_homepage', 0, 1, 1, 0, 0),
 
 ('sys_home', 2, 'system', '', '_sys_page_block_title_profile_stats', 3, 0, 0, 2147483644, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"profile_stats";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 0, 1, 0, 1),
-('sys_home', 3, 'system', '_sys_page_block_title_sys_create_post', '_sys_page_block_title_create_post', 11, 1, 4, 2147483644, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"get_create_post_form";s:6:"params";a:1:{i:0;i:0;}s:5:"class";s:13:"TemplServices";}', 0, 0, 1, 0, 1);
+('sys_home', 3, 'system', '_sys_page_block_title_sys_create_post', '_sys_page_block_title_create_post', 0, 1, 4, 2147483644, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:20:"get_create_post_form";s:6:"params";a:1:{i:0;i:0;}s:5:"class";s:13:"TemplServices";}', 0, 0, 1, 0, 1);
 
 -- content blocks for APP (activated via separate enable-app-pages.sql)
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `title`, `description`, `icon`, `designbox_id`, `class`, `submenu`, `tabs`, `async`, `visible_for_levels`, `hidden_on`, `type`, `content`, `content_empty`, `text`, `text_updated`, `help`, `cache_lifetime`, `config_api`, `deletable`, `copyable`, `active`, `active_api`, `order`) VALUES

+ 26 - 0
tests/units/install/SystemSqlDefaultsTest.php

@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * Defaults a fresh install gets from install/sql/system.sql. Read from the SQL itself, so a site whose admin
+ * changed a setting in Studio does not fail the suite.
+ */
+class SystemSqlDefaultsTest extends \PHPUnit\Framework\TestCase
+{
+    private static function systemSql(): string
+    {
+        $sSql = file_get_contents(__DIR__ . '/../../../install/sql/system.sql');
+        if ($sSql === false)
+            self::fail('install/sql/system.sql is not readable.');
+
+        return $sSql;
+    }
+
+    public function testHomeCreatePostBlockIsContentOnly(): void
+    {
+        // The home page's create-post block: designbox_id follows object, cell, module, title_system and title.
+        $bFound = preg_match("/\\('sys_home', \\d+, 'system', '_sys_page_block_title_sys_create_post', '_sys_page_block_title_create_post', (\\d+),/", self::systemSql(), $aMatch);
+
+        $this->assertSame(1, $bFound, 'system.sql adds the create-post block to the home page.');
+        $this->assertSame(0, (int)$aMatch[1], 'It shows only its form: the content-only design box (BX_DB_CONTENT_ONLY).');
+    }
+}