Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046940
D127.id303.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jun 29, 11:05 AM
Size
4 KB
Mime Type
text/x-diff
Expires
Mon, Jun 30, 11:05 AM (2 h, 2 m)
Engine
blob
Format
Raw Data
Handle
676796
Attached To
D127: INP-1474 - Add "placeholder_label" parameter to "st:ContentBlock" tag
D127.id303.diff
View Options
Index: core/install/install_schema.sql
===================================================================
--- core/install/install_schema.sql
+++ core/install/install_schema.sql
@@ -1171,6 +1171,7 @@
l3_Content text,
l4_Content text,
l5_Content text,
+ PlaceholderLabel varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (PageContentId),
KEY ContentNum (ContentNum,PageId),
KEY RevisionId (RevisionId)
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql
+++ core/install/upgrades.sql
@@ -3026,3 +3026,5 @@
UPDATE Modules
SET ClassNamespace = 'InPortal\\Core'
WHERE `Name` IN ('Core', 'In-Portal');
+
+ALTER TABLE PageContent ADD PlaceholderLabel VARCHAR(255) NOT NULL DEFAULT '';
Index: core/units/categories/categories_tag_processor.php
===================================================================
--- core/units/categories/categories_tag_processor.php
+++ core/units/categories/categories_tag_processor.php
@@ -1219,6 +1219,7 @@
function ContentBlock($params)
{
$num = getArrayValue($params, 'num');
+ $placeholder_label = isset($params['placeholder_label']) ? $params['placeholder_label'] : '';
if ( !$num ) {
$name = getArrayValue($params, 'name');
@@ -1247,10 +1248,15 @@
/* @var $content kDBItem */
if ( !$page_helper->loadContentBlock($content, $page, $num) && EDITING_MODE ) {
- $page_helper->createNewContentBlock($page->GetID(), $num);
+ $page_helper->createNewContentBlock($page->GetID(), $num, $placeholder_label);
$page_helper->loadContentBlock($content, $page, $num);
}
+ if ( $content->GetDBField('PlaceholderLabel') != $placeholder_label ) {
+ $content->SetDBField('PlaceholderLabel', $placeholder_label);
+ $content->Update();
+ }
+
$edit_code_before = $edit_code_after = '';
$inline_editing = isset($params['mode']) && $params['mode'] == 'inline';
@@ -1294,6 +1300,10 @@
$data = $content->GetField('Content');
}
+ if ( EDITING_MODE == EDITING_MODE_CONTENT && empty($data) && !empty($placeholder_label) ) {
+ $data = $this->Application->Phrase($placeholder_label);
+ }
+
$data = $edit_code_before . $this->_transformContentBlockData($data, $params) . $edit_code_after;
if ( $data != '' ) {
Index: core/units/content/content_config.php
===================================================================
--- core/units/content/content_config.php
+++ core/units/content/content_config.php
@@ -71,5 +71,6 @@
'formatter' => 'kMultiLanguage', 'using_fck' => 1,
'default' => ''
),
+ 'PlaceholderLabel' => array('type' => 'string', 'max_len' => 255, 'default' => ''),
),
-);
\ No newline at end of file
+);
Index: core/units/content/content_eh.php
===================================================================
--- core/units/content/content_eh.php
+++ core/units/content/content_eh.php
@@ -38,6 +38,29 @@
}
/**
+ * Occurs before updating item
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnBeforeItemUpdate(kEvent $event)
+ {
+ parent::OnBeforeItemUpdate($event);
+
+ /** @var kDBItem $object */
+ $object = $event->getObject();
+
+ $placeholder_label = $object->GetDBField('PlaceholderLabel');
+
+ if ( !empty($placeholder_label)
+ && $object->GetField('Content') == $this->Application->Phrase($placeholder_label)
+ ) {
+ $object->SetDBField('Content', '');
+ }
+ }
+
+ /**
* Saves changes to a content block (+ creates draft if missing)
*
* @param kEvent $event
Index: core/units/helpers/page_helper.php
===================================================================
--- core/units/helpers/page_helper.php
+++ core/units/helpers/page_helper.php
@@ -368,8 +368,9 @@
*
* @param int $page_id
* @param int $num
+ * @param string $placeholder_label Placeholder label.
*/
- public function createNewContentBlock($page_id, $num)
+ public function createNewContentBlock($page_id, $num, $placeholder_label)
{
$sql = 'SELECT pc.PageContentId, pr.RevisionId
FROM ' . TABLE_PREFIX . 'PageRevisions pr
@@ -395,6 +396,7 @@
$content_block->SetDBField('PageId', $page_id);
$content_block->SetDBField('ContentNum', $num);
+ $content_block->SetDBField('PlaceholderLabel', $placeholder_label);
foreach ($revisions as $revision_id => $content_block_id) {
if ( is_numeric($content_block_id) ) {
Event Timeline
Log In to Comment