Index: branches/5.2.x/core/install/english.lang
===================================================================
--- branches/5.2.x/core/install/english.lang
+++ branches/5.2.x/core/install/english.lang
@@ -1744,6 +1744,7 @@
Tm90aWZ5IE93bmVyIG9mIENoYW5nZXM=
T3JpZ2luYWwgSXRlbSBJRA==
T3duZXIgVXNlciBJRA==
+ UGFnZSBDb250ZW50
UGFyZW50IElE
UGFyZW50IFBhdGg=
SXRlbSBJcyBQb3B1bGFy
Index: branches/5.2.x/core/install/install_data.sql
===================================================================
--- branches/5.2.x/core/install/install_data.sql
+++ branches/5.2.x/core/install/install_data.sql
@@ -994,6 +994,7 @@
INSERT INTO SearchConfig VALUES ('Users', 'Email', -1, 0, 'lu_fielddesc_user_email', 'lu_field_email', 'In-Portal', 'la_text_user', 5, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO SearchConfig VALUES ('Users', 'LastName', -1, 0, 'lu_fielddesc_user_lastname', 'lu_field_lastname', 'In-Portal', 'la_text_user', 4, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO SearchConfig VALUES ('Users', 'FirstName', -1, 0, 'lu_fielddesc_user_firstname', 'lu_field_firstname', 'In-Portal', 'la_text_user', 3, DEFAULT, 0, 'text', NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+INSERT INTO SearchConfig VALUES ('Categories', 'PageContent', 1, 1, 'lu_fielddesc_category_PageContent', 'lc_field_PageContent', 'In-Portal', 'la_text_category', 22, DEFAULT, 1, 'text', 'MULTI:PageRevisions.PageContent', '{ForeignTable}.PageId = {LocalTable}.CategoryId AND {ForeignTable}.RevisionNumber = {LocalTable}.LiveRevisionNumber', NULL, NULL, NULL, NULL, NULL);
INSERT INTO StatItem VALUES (DEFAULT, 'In-Portal', 'SELECT count(*) FROM <%prefix%>Categories WHERE Status=1 ', NULL, 'la_prompt_ActiveCategories', '0', '1');
INSERT INTO StatItem VALUES (DEFAULT, 'In-Portal', 'SELECT count(*) FROM <%prefix%>Users WHERE Status=1 ', NULL, 'la_prompt_ActiveUsers', '0', '1');
Index: branches/5.2.x/core/install/install_schema.sql
===================================================================
--- branches/5.2.x/core/install/install_schema.sql
+++ branches/5.2.x/core/install/install_schema.sql
@@ -1140,6 +1140,11 @@
RevisionNumber int(11) NOT NULL,
IsDraft tinyint(4) NOT NULL,
FromRevisionId int(11) NOT NULL,
+ l1_PageContent longtext null,
+ l2_PageContent longtext null,
+ l3_PageContent longtext null,
+ l4_PageContent longtext null,
+ l5_PageContent longtext null,
CreatedById int(11) DEFAULT NULL,
CreatedOn int(11) DEFAULT NULL,
AutoSavedOn int(11) DEFAULT NULL,
Index: branches/5.2.x/core/install/upgrades.php
===================================================================
--- branches/5.2.x/core/install/upgrades.php
+++ branches/5.2.x/core/install/upgrades.php
@@ -2359,6 +2359,35 @@
}
/**
+ * Update to 5.2.2-B3
+ *
+ * @param string $mode When called mode {before, after).
+ *
+ * @return void
+ */
+ public function Upgrade_5_2_2_B3($mode)
+ {
+ if ( $mode != 'before' ) {
+ return;
+ }
+
+ /** @var kMultiLanguageHelper $ml_helper */
+ $ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
+ $ml_helper->createFields('page-revision');
+
+ /** @var PageHelper $page_helper */
+ $page_helper = $this->Application->recallObject('PageHelper');
+ $table_name = TABLE_PREFIX . 'PageRevisions';
+ $sql = 'SELECT RevisionId
+ FROM ' . $table_name;
+ $ids = $this->Conn->GetColIterator($sql);
+
+ foreach ( $ids as $id ) {
+ $this->Conn->doUpdate($page_helper->getRevisionContent($id), $table_name, 'RevisionId = ' . $id);
+ }
+ }
+
+ /**
* Deletes folders, containing thumbnails recursively.
*
* @param string $folder Folder.
Index: branches/5.2.x/core/install/upgrades.sql
===================================================================
--- branches/5.2.x/core/install/upgrades.sql
+++ branches/5.2.x/core/install/upgrades.sql
@@ -2952,3 +2952,6 @@
WHERE PhraseKey = 'LA_TITLE_SYSTEMTOOLSDEPLOY';
INSERT INTO SystemSettings VALUES(DEFAULT, 'EmailDelivery', '2', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsMailling', 'la_config_EmailDelivery', 'radio', NULL, '1=la_opt_EmailDeliveryQueue||2=la_opt_EmailDeliveryImmediate', 50.11, 0, 1, NULL);
+
+# ===== v 5.2.2-B3 =====
+INSERT INTO SearchConfig VALUES ('Categories', 'PageContent', 1, 1, 'lu_fielddesc_category_PageContent', 'lc_field_PageContent', 'In-Portal', 'la_text_category', 22, DEFAULT, 1, 'text', 'MULTI:PageRevisions.PageContent', '{ForeignTable}.PageId = {LocalTable}.CategoryId AND {ForeignTable}.RevisionNumber = {LocalTable}.LiveRevisionNumber', NULL, NULL, NULL, NULL, NULL);
Index: branches/5.2.x/core/units/categories/categories_config.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_config.php
+++ branches/5.2.x/core/units/categories/categories_config.php
@@ -452,6 +452,9 @@
'IsNew' => Array ('type' => 'int', 'default' => 0),
'OldPriority' => Array ('type' => 'int', 'default' => 0),
+ // For search.
+ 'PageContent' => array('type' => 'string', 'default' => ''),
+
// for primary image
'AltName' => Array ('type' => 'string', 'default' => ''),
'SameImages' => Array ('type' => 'string', 'default' => ''),
Index: branches/5.2.x/core/units/helpers/page_helper.php
===================================================================
--- branches/5.2.x/core/units/helpers/page_helper.php
+++ branches/5.2.x/core/units/helpers/page_helper.php
@@ -438,4 +438,50 @@
return $content_block->isLoaded();
}
+
+ /**
+ * Returns revision content
+ *
+ * @param integer $page_revision_id Page revision Id.
+ *
+ * @return array
+ */
+ public function getRevisionContent($page_revision_id)
+ {
+ $sql = 'SELECT *
+ FROM ' . TABLE_PREFIX . 'PageContent
+ WHERE RevisionId = ' . $page_revision_id;
+ $blocks = $this->Conn->GetIterator($sql);
+
+ /** @var kMultiLanguageHelper $ml_helper */
+ $ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
+ $content = array();
+
+ foreach ( $ml_helper->getLanguages() as $lang_id ) {
+ $parts = array();
+
+ foreach ( $blocks as $block_data ) {
+ if ( (string)$block_data['l' . $lang_id . '_Content'] !== '' ) {
+ $parts[] = $this->makeSearchable($block_data['l' . $lang_id . '_Content']);
+ }
+ }
+
+ $content['l' . $lang_id . '_PageContent'] = implode(' ', $parts);
+ }
+
+ return $content;
+ }
+
+ /**
+ * Unescapes and removes tags
+ *
+ * @param string $content Content.
+ *
+ * @return string
+ */
+ protected function makeSearchable($content)
+ {
+ return trim(strip_tags(html_entity_decode($content, ENT_QUOTES, 'UTF-8')));
+ }
+
}
Index: branches/5.2.x/core/units/page_revisions/page_revision_eh.php
===================================================================
--- branches/5.2.x/core/units/page_revisions/page_revision_eh.php
+++ branches/5.2.x/core/units/page_revisions/page_revision_eh.php
@@ -372,4 +372,28 @@
return $max_revision + 1;
}
+
+ /**
+ * Updates searchable page content
+ *
+ * @param kEvent $event Event.
+ *
+ * @return void
+ */
+ protected function OnAfterPageContentChangedHook(kEvent $event)
+ {
+ /** @var kDBItem $content */
+ $content = $event->MasterEvent->getObject();
+
+ /** @var kDBItem $object */
+ $object = $event->getObject(array('skip_autoload' => true));
+ $revision_id = $content->GetDBField('RevisionId');
+ $object->Load($revision_id);
+
+ /** @var PageHelper $page_helper */
+ $page_helper = $this->Application->recallObject('PageHelper');
+ $object->SetDBFieldsFromHash($page_helper->getRevisionContent($revision_id));
+ $object->Update();
+ }
+
}
Index: branches/5.2.x/core/units/page_revisions/page_revisions_config.php
===================================================================
--- branches/5.2.x/core/units/page_revisions/page_revisions_config.php
+++ branches/5.2.x/core/units/page_revisions/page_revisions_config.php
@@ -21,6 +21,19 @@
'EventHandlerClass' => Array ('class' => 'PageRevisionEventHandler', 'file' => 'page_revision_eh.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'PageRevisionTagProcessor', 'file' => 'page_revision_tp.php', 'build_event' => 'OnBuild'),
+ 'Hooks' => array(
+ array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'content',
+ 'HookToSpecial' => '*',
+ 'HookToEvent' => array('OnAfterItemCreate', 'OnAfterItemUpdate', 'OnAfterItemDelete'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnAfterPageContentChangedHook',
+ ),
+ ),
+
'AutoLoad' => true,
'QueryString' => Array (
@@ -74,6 +87,11 @@
'not_null' => 1, 'default' => 0
),
'FromRevisionId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
+ 'PageContent' => array(
+ 'type' => 'string',
+ 'formatter' => 'kMultiLanguage', 'db_type' => 'longtext',
+ 'default' => null,
+ ),
'CreatedById' => Array (
'type' => 'int',
'formatter' => 'kLEFTFormatter', 'options' => Array (USER_ROOT => 'root', USER_GUEST => 'Guest'), 'left_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Users WHERE %s', 'left_key_field' => 'PortalUserId', 'left_title_field' => USER_TITLE_FIELD, 'error_msgs' => Array ('invalid_option' => '!la_error_UserNotFound!'), 'sample_value' => 'Guest', 'required' => 1,