diff --git a/languages/onoffice-for-wp-websites-de_DE.mo b/languages/onoffice-for-wp-websites-de_DE.mo index cda39afe2..c306dd4d0 100644 Binary files a/languages/onoffice-for-wp-websites-de_DE.mo and b/languages/onoffice-for-wp-websites-de_DE.mo differ diff --git a/languages/onoffice-for-wp-websites-de_DE.po b/languages/onoffice-for-wp-websites-de_DE.po index 598aa239b..2ae5ccafc 100644 --- a/languages/onoffice-for-wp-websites-de_DE.po +++ b/languages/onoffice-for-wp-websites-de_DE.po @@ -738,9 +738,37 @@ msgstr "Absteigend" msgid "Template" msgstr "Template" +#: plugin/Gui/Table/EstateListTable.php:133 +msgid "List name" +msgstr "Listennamen" + +#: plugin/Gui/Table/EstateListTable.php:134 +msgid "Selected filter" +msgstr "Ausgewählter Filter" + +#: plugin/Gui/Table/EstateListTable.php:136 +msgid "List type" +msgstr "Listentyp" + +#: plugin/Gui/Table/EstateListTable.php:138 +msgid "Pages using the shortcode" +msgstr "Seiten, die den Shortcode verwenden" + +#: plugin/Gui/Table/AddressListTable.php:128 +msgid "Form name" +msgstr "Formularname" + +#: plugin/Gui/Table/AddressListTable.php:129 +msgid "Recipient e-mail address" +msgstr "Empfänger E-Mail-Adresse" + +#: plugin/Gui/Table/AddressListTable.php:131 +msgid "Form type" +msgstr "Formulartyp" + #: plugin/Model/FormModelBuilder/FormModelBuilderDBAddress.php:94 -#: plugin/Model/FormModelBuilder/FormModelBuilderDBEstateListSettings.php:119 -msgid "List View" +#: plugin/Gui/Table/EstateListTable.php:134 +msgid "Selected filter" msgstr "Listenansicht" #: plugin/Model/FormModelBuilder/FormModelBuilderDBAddress.php:148 diff --git a/languages/onoffice-for-wp-websites-es_ES.mo b/languages/onoffice-for-wp-websites-es_ES.mo index 7c234ecab..5c9c54259 100644 Binary files a/languages/onoffice-for-wp-websites-es_ES.mo and b/languages/onoffice-for-wp-websites-es_ES.mo differ diff --git a/languages/onoffice-for-wp-websites-es_ES.po b/languages/onoffice-for-wp-websites-es_ES.po index 67012675b..f474f8810 100644 --- a/languages/onoffice-for-wp-websites-es_ES.po +++ b/languages/onoffice-for-wp-websites-es_ES.po @@ -741,6 +741,34 @@ msgstr "Descendente" msgid "Template" msgstr "Plantilla" +#: plugin/Gui/Table/EstateListTable.php:133 +msgid "List name" +msgstr "Lista de nombres" + +#: plugin/Gui/Table/EstateListTable.php:134 +msgid "Selected filter" +msgstr "Filtro seleccionado" + +#: plugin/Gui/Table/EstateListTable.php:136 +msgid "List type" +msgstr "Tipo de lista" + +#: plugin/Gui/Table/EstateListTable.php:138 +msgid "Pages using the shortcode" +msgstr "Páginas que usan el shortcode" + +#: plugin/Gui/Table/AddressListTable.php:128 +msgid "Form name" +msgstr "Nombre del formulario" + +#: plugin/Gui/Table/AddressListTable.php:129 +msgid "Recipient e-mail address" +msgstr "Dirección de Correo Electrónico del Destinatario" + +#: plugin/Gui/Table/AddressListTable.php:131 +msgid "Form type" +msgstr "tipo de formulario" + #: plugin/Model/FormModelBuilder/FormModelBuilderDBAddress.php:94 #: plugin/Model/FormModelBuilder/FormModelBuilderDBEstateListSettings.php:119 msgid "List View" diff --git a/languages/onoffice-for-wp-websites-it_IT.mo b/languages/onoffice-for-wp-websites-it_IT.mo index b628a79ec..71ae355b9 100644 Binary files a/languages/onoffice-for-wp-websites-it_IT.mo and b/languages/onoffice-for-wp-websites-it_IT.mo differ diff --git a/languages/onoffice-for-wp-websites-it_IT.po b/languages/onoffice-for-wp-websites-it_IT.po index 839e1e3ed..96198a973 100644 --- a/languages/onoffice-for-wp-websites-it_IT.po +++ b/languages/onoffice-for-wp-websites-it_IT.po @@ -741,6 +741,34 @@ msgstr "Scendendo" msgid "Template" msgstr "Modello" +#: plugin/Gui/Table/EstateListTable.php:133 +msgid "List name" +msgstr "Lista nome" + +#: plugin/Gui/Table/EstateListTable.php:134 +msgid "Selected filter" +msgstr "Filtro selezionato" +#: plugin/Gui/Table/EstateListTable.php:136 +msgid "List type" +msgstr "Tipo di elenco" + +#: plugin/Gui/Table/EstateListTable.php:138 +msgid "Pages using the shortcode" +msgstr "Pagine che utilizzano lo shortcode" + +#: plugin/Gui/Table/AddressListTable.php:128 +msgid "Form name" +msgstr "Nome del modulo" + +#: plugin/Gui/Table/AddressListTable.php:129 +msgid "Recipient e-mail address" +msgstr "Indirizzo e-mail del destinatario" + +#: plugin/Gui/Table/AddressListTable.php:131 +msgid "Form type" +msgstr "Tipo di modulo" + + #: plugin/Model/FormModelBuilder/FormModelBuilderDBAddress.php:94 #: plugin/Model/FormModelBuilder/FormModelBuilderDBEstateListSettings.php:119 msgid "List View" diff --git a/languages/onoffice-for-wp-websites-nl_NL.mo b/languages/onoffice-for-wp-websites-nl_NL.mo index 1ed1bf872..c5346ba4c 100644 Binary files a/languages/onoffice-for-wp-websites-nl_NL.mo and b/languages/onoffice-for-wp-websites-nl_NL.mo differ diff --git a/languages/onoffice-for-wp-websites-nl_NL.po b/languages/onoffice-for-wp-websites-nl_NL.po index 6bd71b2fe..d77f672b3 100644 --- a/languages/onoffice-for-wp-websites-nl_NL.po +++ b/languages/onoffice-for-wp-websites-nl_NL.po @@ -735,7 +735,7 @@ msgstr "Aflopend" #: plugin/Model/FormModelBuilder/FormModelBuilderDB.php:193 #: plugin/Model/FormModelBuilder/FormModelBuilderEstateDetailSettings.php:245 #: plugin/Model/FormModelBuilder/FormModelBuilderSimilarEstateSettings.php:215 -msgid "Template" +msgid "Templates" msgstr "Sjabloon" #: plugin/Model/FormModelBuilder/FormModelBuilderDBAddress.php:94 @@ -743,6 +743,34 @@ msgstr "Sjabloon" msgid "List View" msgstr "Lijstweergave" +#: plugin/Gui/Table/EstateListTable.php:133 +msgid "List name" +msgstr "Lijstnaam" + +#: plugin/Gui/Table/EstateListTable.php:134 +msgid "Selected filter" +msgstr "Geselecteerd filter" + +#: plugin/Gui/Table/EstateListTable.php:136 +msgid "List type" +msgstr "Lijsttype" + +#: plugin/Gui/Table/EstateListTable.php:138 +msgid "Pages using the shortcode" +msgstr "Pagina's die de shortcode gebruiken" + +#: plugin/Gui/Table/AddressListTable.php:128 +msgid "Form name" +msgstr "Formulier naam" + +#: plugin/Gui/Table/AddressListTable.php:129 +msgid "Recipient e-mail address" +msgstr "Emailadres van ontvanger" + +#: plugin/Gui/Table/AddressListTable.php:131 +msgid "Form type" +msgstr "Formuliertype" + #: plugin/Model/FormModelBuilder/FormModelBuilderDBAddress.php:148 msgid "Passport Photo" msgstr "Pasfoto" diff --git a/plugin.php b/plugin.php index cb342bbd7..5f1ed959d 100644 --- a/plugin.php +++ b/plugin.php @@ -106,7 +106,7 @@ }, 11); add_action('admin_init', [$pAdminViewController, 'add_ajax_actions']); add_action('admin_init', [CaptchaDataChecker::class, 'addHook']); - +add_action('admin_init', [$pDetailViewPostSaveController, 'getAllPost']); add_action('plugins_loaded', function() { load_plugin_textdomain('onoffice-for-wp-websites', false, basename(ONOFFICE_PLUGIN_DIR) . '/languages'); // Check 'onoffice-personalized' Folder exists diff --git a/plugin/Controller/DetailViewPostSaveController.php b/plugin/Controller/DetailViewPostSaveController.php index 03e1ddf90..799ba15ea 100644 --- a/plugin/Controller/DetailViewPostSaveController.php +++ b/plugin/Controller/DetailViewPostSaveController.php @@ -23,6 +23,10 @@ use onOffice\WPlugin\DataView\DataDetailViewHandler; use onOffice\WPlugin\Utility\__String; +use onOffice\WPlugin\Record\RecordManagerReadListViewEstate; +use onOffice\WPlugin\Record\RecordManagerReadListViewAddress; +use onOffice\WPlugin\Record\RecordManagerReadForm; + use WP_Post; /** @@ -91,6 +95,18 @@ public function onSavePost($postId) { flush_rewrite_rules(); } } + $this->addPageUseShortCode($pPost); + } + + } + public function getAllPost() { + $args = array( + 'post_status' => 'publish', + ); + $posts = get_pages($args); + foreach ($posts as $post) + { + $this->addPageUseShortCode($post); } } @@ -114,6 +130,8 @@ public function onMoveTrash($postId) { $pDataDetailViewHandler->saveDetailView($pDetailView); flush_rewrite_rules(); } + $pPost = get_post($postId); + $this->deletePageUseShortCode($pPost); } @@ -128,7 +146,36 @@ private function generateDetailViewCode($detailViewName) { return 'view="'.$detailViewName.'"'; } - + private function generateDetailCode($detailViewName,$option) { + return $option.'="'.$detailViewName.'"'; + } + private function getListView() + { + $pRecordReadListView = new RecordManagerReadListViewEstate(); + $pRecordReadListView->addColumn('listview_id'); + $pRecordReadListView->addColumn('name'); + $pRecordReadListView->addColumn('page_shortcode'); + $listView = $pRecordReadListView->getRecords(); + return $listView; + } + private function getListViewAddress() + { + $pRecordReadListViewAddress = new RecordManagerReadListViewAddress(); + $pRecordReadListViewAddress->addColumn('listview_address_id'); + $pRecordReadListViewAddress->addColumn('name'); + $pRecordReadListViewAddress->addColumn('page_shortcode'); + $listViewAddress = $pRecordReadListViewAddress->getRecords(); + return $listViewAddress; + } + private function getListForm() + { + $pRecordReadForm = new RecordManagerReadForm(); + $pRecordReadForm->addColumn('form_id'); + $pRecordReadForm->addColumn('name'); + $pRecordReadForm->addColumn('page_shortcode'); + $listForm = $pRecordReadForm->getRecords(); + return $listForm; + } /** * * @param string $post @@ -156,4 +203,133 @@ private function postContainsViewName($post, $viewName) { return false; } + + private function postContains($post, $viewName, $element,$option) { + $matches = array(); + $regex = get_shortcode_regex(array($element)); + preg_match_all('/'.$regex.'/ism', $post, $matches); + + $detailviewCode = $this->generateDetailCode($viewName,$option); + if (!array_key_exists(3, $matches)) { + return false; + } + + foreach ($matches[3] as $tagParams) { + if (__String::getNew($tagParams)->contains($detailviewCode)) { + return true; + } + } + + return false; + } + + private function addPageUseShortCode($post) + { + $listView = $this->getListView(); + $listViewAddress = $this->getListViewAddress(); + $listForm = $this->getListForm(); + $isRevision = wp_is_post_revision($post); + if (!$isRevision) { + $postContent = $post->post_content; + $postID = $post->ID; + if (empty($postID)) + { + return; + } + if (strpos($postContent,'oo_estate') !== false) + { + $this->addPageShortCode($listView,$post,'oo_estate','view',"oo_plugin_listviews","listview_id","listview_id"); + } + if (strpos($postContent,'oo_address') !== false) + { + $this->addPageShortCode($listViewAddress,$post,'oo_address','view',"oo_plugin_listviews_address","listview_address_id","listview_address_id"); + } + if (strpos($postContent,'oo_form') !== false) + { + $this->addPageShortCode($listForm,$post,'oo_form','form',"oo_plugin_forms","form_id","form_id"); + } + + } + } + private function deletePageUseShortCode($post) + { + $listView = $this->getListView(); + $listViewAddress = $this->getListViewAddress(); + $listForm = $this->getListForm(); + $isRevision = wp_is_post_revision($post); + + if (!$isRevision) { + $postContent = $post->post_content; + $postID = $post->ID; + if (empty($postID)) + { + return; + } + if (strpos($postContent,'oo_estate') !== false) + { + $this->deletePageShortCode($listView,$post,"oo_plugin_listviews","listview_id","listview_id"); + } + if (strpos($postContent,'oo_address') !== false) + { + $this->deletePageShortCode($listViewAddress,$post,"oo_plugin_listviews_address","listview_address_id","listview_address_id"); + } + if (strpos($postContent,'oo_form') !== false) + { + $this->deletePageShortCode($listForm,$post,"oo_plugin_forms","form_id","form_id"); + } + + } + } + private function addPageShortCode($listView,$post,$element,$option,$tableName,$column,$primaKey) + { + $pRecordReadListView = new RecordManagerReadListViewEstate(); + $postID = $post->ID; + $postContent = $post->post_content; + foreach($listView as $view) + { + $pageID = []; + if (!empty($view->page_shortcode)) + { + $pageID = explode(',',$view->page_shortcode); + } + if (in_array($postID,$pageID)) + { + break; + } + $viewContained = $this->postContains($postContent, $view->name,$element,$option); + if ($viewContained) { + if (empty($pageID)) + { + $pageID = $postID; + }else { + $pageID[] = $postID; + $pageID = implode(",",$pageID); + } + $pRecordReadListView->updateColumnPageShortCode($pageID,$view->$primaKey,$tableName,$column); + } + } + } + private function deletePageShortCode($listView,$post,$tableName,$column,$primaKey) + { + $pRecordReadListView = new RecordManagerReadListViewEstate(); + $postID = $post->ID; + foreach($listView as $view) + { + $pageID = ''; + if (empty($view->page_shortcode)) + { + continue; + } + if (strpos($view->page_shortcode,(string)$postID)!== false) + { + $pageShortCode = explode(",",$view->page_shortcode); + if (($keyPageDelete = array_search($postID, $pageShortCode)) !== false) { + unset($pageShortCode[$keyPageDelete]); + } + $pageID = implode(",",$pageShortCode); + $pRecordReadListView->updateColumnPageShortCode($pageID,$view->$primaKey,$tableName,$column); + } + + } + } } diff --git a/plugin/Gui/Table/AddressListTable.php b/plugin/Gui/Table/AddressListTable.php index 5cae5cb23..09ca98109 100644 --- a/plugin/Gui/Table/AddressListTable.php +++ b/plugin/Gui/Table/AddressListTable.php @@ -23,6 +23,10 @@ use onOffice\WPlugin\Gui\Table\WP\ListTable; use onOffice\WPlugin\Record\RecordManagerReadListViewAddress; +use onOffice\WPlugin\Controller\Exception\UnknownFilterException; +use onOffice\WPlugin\API\APIClientCredentialsException; +use onOffice\WPlugin\FilterCall; +use onOffice\SDK\onOfficeSDK; use function __; use function admin_url; use function esc_html; @@ -43,6 +47,8 @@ class AddressListTable /** @var int */ private $_itemsPerPage = null; + /** @var FilterCall */ + private $_pFilterCall = null; /** * @@ -59,6 +65,7 @@ public function __construct($args = []) ]); $this->_itemsPerPage = $this->get_items_per_page('onoffice-address-listview_per_page', 10); + $this->_pFilterCall = new FilterCall(onOfficeSDK::MODULE_ADDRESS); } @@ -77,9 +84,14 @@ private function fillData() $pRecordRead->setOffset($offset); $pRecordRead->addColumn('listview_address_id', 'ID'); $pRecordRead->addColumn('name'); + $pRecordRead->addColumn('filterId'); + $pRecordRead->addColumn('template'); $pRecordRead->addColumn('name', 'shortcode'); + $pRecordRead->addColumn('page_shortcode'); - $this->setItems($pRecordRead->getRecordsSortedAlphabetically()); + $pRecord = $pRecordRead->getRecordsSortedAlphabetically(); + $pRecord = $this->handleRecord($pRecord); + $this->setItems($pRecord); $itemsCount = $pRecordRead->getCountOverall(); $this->set_pagination_args([ @@ -88,8 +100,29 @@ private function fillData() 'total_pages' => ceil($itemsCount / 10) ]); } + /** + * + * @param object $pItem + * @return string + * + */ - + protected function column_filtername($pItem) + { + $filterName = ''; + try { + if ($pItem->filterId != 0) { + $filterName = $this->_pFilterCall->getFilternameById($pItem->filterId); + } + } catch (APIClientCredentialsException $pCredentialsException) { + $filterName = __('(Needs valid API credentials)', 'onoffice-for-wp-websites'); + } catch (UnknownFilterException $pFilterException) { + /* translators: %s will be replaced with a number. */ + $filterName = sprintf(__('(Unknown Filter (ID: %s))', 'onoffice-for-wp-websites'), + $pFilterException->getFilterId()); + } + return $filterName; + } /** * * @return array @@ -101,6 +134,7 @@ public function get_columns() return [ 'cb' => '', 'name' => __('Name of View', 'onoffice-for-wp-websites'), + 'filtername' => __('Filter', 'onoffice-for-wp-websites'), 'shortcode' => __('Shortcode', 'onoffice-for-wp-websites'), ]; } @@ -143,11 +177,14 @@ public function prepare_items() { $columns = [ 'cb' => '', - 'name' => __('Name of View', 'onoffice-for-wp-websites'), + 'name' => __('List name', 'onoffice-for-wp-websites'), + 'filtername' => __('Selected filter', 'onoffice-for-wp-websites'), + 'template' => __('Template', 'onoffice-for-wp-websites'), 'shortcode' => __('Shortcode', 'onoffice-for-wp-websites'), + 'page_shortcode' => __('Pages using the shortcode', 'onoffice-for-wp-websites'), ]; - $hidden = ['ID']; + $hidden = ['ID','filterId']; $sortable = []; $this->_column_headers = [$columns, $hidden, $sortable, diff --git a/plugin/Gui/Table/EstateListTable.php b/plugin/Gui/Table/EstateListTable.php index 55feb408b..f5e63bd2f 100644 --- a/plugin/Gui/Table/EstateListTable.php +++ b/plugin/Gui/Table/EstateListTable.php @@ -104,12 +104,15 @@ private function fillData() $pRecordRead->addColumn('listview_id', 'ID'); $pRecordRead->addColumn('name'); $pRecordRead->addColumn('filterId'); - $pRecordRead->addColumn('show_status'); + $pRecordRead->addColumn('template'); $pRecordRead->addColumn('list_type'); $pRecordRead->addColumn('name', 'shortcode'); + $pRecordRead->addColumn('page_shortcode'); $pRecordRead->addWhere("`list_type` IN('default', 'reference', 'favorites')"); - $this->setItems($pRecordRead->getRecordsSortedAlphabetically()); + $pRecord = $pRecordRead->getRecordsSortedAlphabetically(); + $pRecord = $this->handleRecord($pRecord); + $this->setItems($pRecord); $itemsCount = $pRecordRead->getCountOverall(); $this->set_pagination_args([ @@ -119,7 +122,6 @@ private function fillData() ]); } - /** * */ @@ -128,11 +130,12 @@ public function prepare_items() { $columns = [ 'cb' => '', - 'name' => __('Name of View', 'onoffice-for-wp-websites'), - 'filtername' => __('Filter', 'onoffice-for-wp-websites'), - 'show_status' => __('Show Status', 'onoffice-for-wp-websites'), - 'list_type' => __('Type of List', 'onoffice-for-wp-websites'), + 'name' => __('List name', 'onoffice-for-wp-websites'), + 'filtername' => __('Selected filter', 'onoffice-for-wp-websites'), + 'template' => __('Template', 'onoffice-for-wp-websites'), + 'list_type' => __('List type', 'onoffice-for-wp-websites'), 'shortcode' => __('Shortcode', 'onoffice-for-wp-websites'), + 'page_shortcode' => __('Pages using the shortcode', 'onoffice-for-wp-websites'), ]; $hidden = ['ID', 'filterId']; diff --git a/plugin/Gui/Table/FormsTable.php b/plugin/Gui/Table/FormsTable.php index bb88192a8..eced1118c 100644 --- a/plugin/Gui/Table/FormsTable.php +++ b/plugin/Gui/Table/FormsTable.php @@ -93,14 +93,18 @@ private function fillData() $pRecordRead->setOffset($offset); $pRecordRead->addColumn('form_id', 'ID'); $pRecordRead->addColumn('name'); + $pRecordRead->addColumn('recipient'); + $pRecordRead->addColumn('template'); $pRecordRead->addColumn('form_type'); $pRecordRead->addColumn('name', 'shortcode'); - + $pRecordRead->addColumn('page_shortcode'); if ($this->_listType != 'all' && $this->_listType != null) { $pRecordRead->addWhere("`form_type` = '".esc_sql($this->_listType)."'"); } - $this->setItems($pRecordRead->getRecordsSortedAlphabetically()); + $pRecord = $pRecordRead->getRecordsSortedAlphabetically(); + $pRecord = $this->handleRecord($pRecord); + $this->setItems($pRecord); $itemsCount = $pRecordRead->getCountOverall(); $this->set_pagination_args( array( @@ -121,9 +125,12 @@ public function prepare_items() { $columns = array( 'cb' => '', - 'name' => __('Name of Form', 'onoffice-for-wp-websites'), - 'form_type' => __('Type of Form', 'onoffice-for-wp-websites'), + 'name' => __('Form name', 'onoffice-for-wp-websites'), + 'recipient' => __('Recipient e-mail address', 'onoffice-for-wp-websites'), + 'template' => __('Template', 'onoffice-for-wp-websites'), + 'form_type' => __('Form type', 'onoffice-for-wp-websites'), 'shortcode' => __('Shortcode', 'onoffice-for-wp-websites'), + 'page_shortcode' => __('Pages using the shortcode', 'onoffice-for-wp-websites'), ); $hidden = array('ID', 'filterId'); diff --git a/plugin/Gui/Table/WP/ListTable.php b/plugin/Gui/Table/WP/ListTable.php index 89b414601..57c3ae504 100644 --- a/plugin/Gui/Table/WP/ListTable.php +++ b/plugin/Gui/Table/WP/ListTable.php @@ -145,4 +145,31 @@ protected function setItems(array $items) /** @return array */ protected function getItems() { return $this->items; } + + protected function handleRecord(array $records) + { + if (empty($records)) + { + return []; + } + $recordHandled = []; + foreach ($records as $record) + { + if (!empty($record->page_shortcode)) + { + $listPageID = explode(',',$record->page_shortcode); + $pages = ''; + $listPage = []; + foreach ($listPageID as $pageID) + { + $listPage[] = "".esc_html(get_the_title((int)$pageID)).""; + } + $pages = implode(',',$listPage); + $record->page_shortcode = $pages; + } + $recordHandled[] = $record; + } + return $recordHandled; + } + } diff --git a/plugin/Installer/DatabaseChanges.php b/plugin/Installer/DatabaseChanges.php index eecc0cae0..aacca599d 100644 --- a/plugin/Installer/DatabaseChanges.php +++ b/plugin/Installer/DatabaseChanges.php @@ -34,7 +34,7 @@ class DatabaseChanges implements DatabaseChangesInterface { /** @var int */ - const MAX_VERSION = 24; + const MAX_VERSION = 25; /** @var WPOptionWrapperBase */ private $_pWpOption; @@ -180,6 +180,12 @@ public function install() $dbversion = 24; } + if ($dbversion == 24) { + dbDelta($this->getCreateQueryListviews()); + dbDelta($this->getCreateQueryListViewsAddress()); + dbDelta($this->getCreateQueryForms()); + $dbversion = 25; + } $this->_pWpOption->updateOption( 'oo_plugin_db_version', $dbversion, true); } @@ -251,6 +257,7 @@ private function getCreateQueryListviews() `sortByUserDefinedDefault` VARCHAR(200) NOT NULL COMMENT 'Standardsortierung', `sortByUserDefinedDirection` ENUM('0','1') NOT NULL DEFAULT '0' COMMENT 'Formulierung der Sortierrichtung: 0 means highestFirst/lowestFirt, 1 means descending/ascending', `show_reference_estate` tinyint(1) NOT NULL DEFAULT '0', + `page_shortcode` tinytext NOT NULL, PRIMARY KEY (`listview_id`), UNIQUE KEY `name` (`name`) ) $charsetCollate;"; @@ -292,6 +299,7 @@ private function getCreateQueryForms() `geo_order` VARCHAR( 255 ) NOT NULL DEFAULT 'street,zip,city,country,radius', `show_estate_context` tinyint(1) NOT NULL DEFAULT '0', `contact_type` varchar(255) NULL DEFAULT NULL, + `page_shortcode` tinytext NOT NULL, PRIMARY KEY (`form_id`), UNIQUE KEY `name` (`name`) ) $charsetCollate;"; @@ -462,6 +470,7 @@ private function getCreateQueryListViewsAddress() `template` tinytext NOT NULL, `recordsPerPage` int(10) NOT NULL DEFAULT '10', `showPhoto` tinyint(1) NOT NULL DEFAULT '0', + `page_shortcode` tinytext NOT NULL, PRIMARY KEY (`listview_address_id`), UNIQUE KEY `name` (`name`) ) $charsetCollate;"; diff --git a/plugin/Record/RecordManagerReadListViewEstate.php b/plugin/Record/RecordManagerReadListViewEstate.php index f2bac378f..e49a46efb 100644 --- a/plugin/Record/RecordManagerReadListViewEstate.php +++ b/plugin/Record/RecordManagerReadListViewEstate.php @@ -390,4 +390,13 @@ public function getContactDataByListviewId($listviewId) { return $this->readContactDataByListviewId($listviewId); } + + public function updateColumnPageShortCode($page,$listviewId,$tableName,$column) + { + $prefix = $this->getTablePrefix(); + $pWpDb = $this->getWpdb(); + $pWpDb->query("UPDATE {$prefix}".$tableName." + SET `page_shortcode` ='" .$page."' + WHERE `".$column."` = ".esc_sql($listviewId)); + } } diff --git a/tests/TestClassDatabaseChanges.php b/tests/TestClassDatabaseChanges.php index 8af9a9aaf..be6ec05f5 100644 --- a/tests/TestClassDatabaseChanges.php +++ b/tests/TestClassDatabaseChanges.php @@ -111,12 +111,13 @@ public function testInstall(): array $this->assertGreaterThanOrEqual(self::NUM_NEW_TABLES, count($this->_createQueries)); $dbversion = $this->_pDbChanges->getDbVersion(); - $this->assertEquals(24, $dbversion); + $this->assertEquals(25, $dbversion); return $this->_createQueries; } public function testInstallMigrationsDataSimilarEstates(): array { + $this->_pDbChanges->deinstall(); add_option('oo_plugin_db_version', '16'); add_filter('query', [$this, 'saveCreateQuery'], 1); $this->_pDbChanges->install(); @@ -191,7 +192,7 @@ public function testDeleteCommentFieldApplicantSearchForm() */ public function testMaxVersion() { - $this->assertEquals(24, DatabaseChanges::MAX_VERSION); + $this->assertEquals(25, DatabaseChanges::MAX_VERSION); } diff --git a/tests/TestClassWPPageWrapper.php b/tests/TestClassWPPageWrapper.php index 93573f282..17a6453cd 100644 --- a/tests/TestClassWPPageWrapper.php +++ b/tests/TestClassWPPageWrapper.php @@ -26,7 +26,9 @@ use onOffice\WPlugin\WP\UnknownPageException; use onOffice\WPlugin\WP\WPPageWrapper; use WP_UnitTestCase; - +use onOffice\WPlugin\Installer\DatabaseChanges; +use onOffice\WPlugin\Utility\__String; +use onOffice\WPlugin\WP\WPOptionWrapperTest; /** * @preserveGlobalState disabled @@ -61,6 +63,11 @@ class TestClassWPPageWrapper */ public function prepare() { + global $wpdb; + + $pWpOption = new WPOptionWrapperTest(); + $pDbChanges = new DatabaseChanges($pWpOption, $wpdb); + $pDbChanges->install(); $this->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); $this->_pSubject = new WPPageWrapper(); // set this even though the permalink for pages always is %postname% @@ -71,7 +78,6 @@ public function prepare() 'post_status' => 'publish', 'post_date' => '2016-05-01 13:37:37', ]); - $postData = self::POST_DATA; $postData['post_parent'] = $this->_ancestorId; $this->_postId = wp_insert_post($postData);