Page MenuHomeIn-Portal Phabricator

D127.id.diff
No OneTemporary

File Metadata

Created
Sun, Jun 29, 9:52 AM

D127.id.diff

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