Skip to content

Commit

Permalink
возможность пропустить загрузку дополнения по ftp
Browse files Browse the repository at this point in the history
без необходимости перепаковки архива дополнения,
fulltext индексы в дампах, переработан компонент поиска,
в него добавлена поддержка других компонентов через хук,
в результатах поиска теперь выводится изображение записи если есть,
в поля типа caption, text и html добавлена опция "Участвует в полнотекстовом поиске",
при включении которой fulltext индекс перестраивается и поисковый запрос полноценно использует индекс
+ исправлено несколько мелких ошибок
  • Loading branch information
fuze committed Dec 10, 2015
1 parent 15fd7d2 commit c1354de
Show file tree
Hide file tree
Showing 26 changed files with 342 additions and 90 deletions.
8 changes: 4 additions & 4 deletions install/languages/en/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ CREATE TABLE `{#}con_albums` (
KEY `category_id` (`category_id`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`)
KEY `date_pub_end` (`date_pub_end`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `{#}con_albums_cats`;
Expand Down Expand Up @@ -408,11 +408,11 @@ CREATE TABLE `{#}con_pages` (
KEY `category_id` (`category_id`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`)
KEY `date_pub_end` (`date_pub_end`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `{#}con_pages_cats`;
Expand Down
12 changes: 6 additions & 6 deletions install/languages/en/base_demo_content.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ CREATE TABLE `{#}con_articles` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_reviews` (`kind`,`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `dataset_featured` (`featured`,`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `dataset_rating` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`)
KEY `dataset_rating` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_articles` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `teaser`, `kind`, `notice`, `source`, `featured`) VALUES
Expand Down Expand Up @@ -273,13 +273,13 @@ CREATE TABLE `{#}con_news` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_discussed` (`is_pub`,`is_parent_hidden`,`is_approved`,`comments`),
KEY `dataset_popular` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`)
KEY `dataset_popular` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_news` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `teaser`, `photo`) VALUES
Expand Down Expand Up @@ -460,12 +460,12 @@ CREATE TABLE `{#}con_posts` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_daily` (`date_pub`,`is_pub`,`is_parent_hidden`,`is_approved`,`rating`)
KEY `dataset_daily` (`date_pub`,`is_pub`,`is_parent_hidden`,`is_approved`,`rating`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_posts` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `picture`) VALUES
Expand Down
12 changes: 6 additions & 6 deletions install/languages/ru/base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CREATE TABLE `{#}content_datasets` (
KEY `is_visible` (`is_visible`),
KEY `ctype_id` (`ctype_id`,`ordering`),
KEY `index` (`index`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Наборы для типов контента';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Наборы для типов контента';

DROP TABLE IF EXISTS `{#}content_folders`;
CREATE TABLE `{#}content_folders` (
Expand Down Expand Up @@ -257,11 +257,11 @@ CREATE TABLE `{#}con_albums` (
KEY `category_id` (`category_id`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`)
KEY `date_pub_end` (`date_pub_end`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `{#}con_albums_cats`;
Expand Down Expand Up @@ -407,11 +407,11 @@ CREATE TABLE `{#}con_pages` (
KEY `category_id` (`category_id`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`)
KEY `date_pub_end` (`date_pub_end`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `{#}con_pages_cats`;
Expand Down Expand Up @@ -1044,7 +1044,7 @@ CREATE TABLE `{#}users_friends` (
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`,`is_mutual`),
KEY `friend_id` (`friend_id`,`is_mutual`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Дружба пользователей';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Дружба пользователей';

DROP TABLE IF EXISTS `{#}users_groups`;
CREATE TABLE `{#}users_groups` (
Expand Down
16 changes: 8 additions & 8 deletions install/languages/ru/base_demo_content.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ CREATE TABLE `{#}con_articles` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_reviews` (`kind`,`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `dataset_featured` (`featured`,`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `dataset_rating` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`)
KEY `dataset_rating` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_articles` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `teaser`, `kind`, `notice`, `source`, `featured`) VALUES
Expand Down Expand Up @@ -283,12 +283,12 @@ CREATE TABLE `{#}con_board` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_cheap` (`is_pub`,`is_parent_hidden`,`is_approved`,`price`)
KEY `dataset_cheap` (`is_pub`,`is_parent_hidden`,`is_approved`,`price`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_board` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `photo`, `photos`, `price`, `phone`) VALUES
Expand Down Expand Up @@ -571,13 +571,13 @@ CREATE TABLE `{#}con_news` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_discussed` (`is_pub`,`is_parent_hidden`,`is_approved`,`comments`),
KEY `dataset_popular` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`)
KEY `dataset_popular` (`is_pub`,`is_parent_hidden`,`is_approved`,`rating`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_news` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `teaser`, `photo`) VALUES
Expand Down Expand Up @@ -760,12 +760,12 @@ CREATE TABLE `{#}con_posts` (
KEY `approved_by` (`approved_by`),
KEY `folder_id` (`folder_id`),
KEY `slug` (`slug`),
KEY `title` (`title`),
KEY `date_pub` (`is_pub`,`is_parent_hidden`,`is_approved`,`date_pub`),
KEY `parent_id` (`parent_id`,`parent_type`,`date_pub`),
KEY `user_id` (`user_id`,`date_pub`),
KEY `date_pub_end` (`date_pub_end`),
KEY `dataset_daily` (`date_pub`,`is_pub`,`is_parent_hidden`,`is_approved`,`rating`)
KEY `dataset_daily` (`date_pub`,`is_pub`,`is_parent_hidden`,`is_approved`,`rating`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

INSERT INTO `{#}con_posts` (`id`, `title`, `content`, `slug`, `seo_keys`, `seo_desc`, `seo_title`, `tags`, `date_pub`, `date_last_modified`, `date_pub_end`, `is_pub`, `hits_count`, `user_id`, `parent_id`, `parent_type`, `parent_title`, `parent_url`, `is_parent_hidden`, `category_id`, `folder_id`, `is_comments_on`, `comments`, `rating`, `is_approved`, `approved_by`, `date_approved`, `is_private`, `picture`) VALUES
Expand Down
2 changes: 1 addition & 1 deletion system/controllers/admin/actions/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private function showPackageInfo($package_name, $is_no_extract=false){
}

// если это пакет обновления, а полная версия не установлена
if(empty($manifest['package']['installed_version']) && $manifest['package']['action'] == 'update'){
if(isset($manifest['package']) && empty($manifest['package']['installed_version']) && $manifest['package']['action'] == 'update'){

files_clear_directory(cmsConfig::get('upload_path') . $this->installer_upload_path);

Expand Down
2 changes: 1 addition & 1 deletion system/controllers/admin/actions/install_finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function doPackage() {

}

return true;
return '';

}

Expand Down
19 changes: 15 additions & 4 deletions system/controllers/admin/forms/form_ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function init() {

new fieldString('path', array(
'title' => LANG_CP_FTP_PATH,
'hint' => LANG_CP_FTP_PATH_HINT,
'hint' => LANG_CP_FTP_PATH_HINT,
'default' => '/',
'rules' => array(
array('required'),
Expand All @@ -40,16 +40,27 @@ public function init() {

)
),

array(
'type' => 'fieldset',
'childs' => array(
new fieldCheckbox('is_pasv', array(
'title' => LANG_CP_FTP_IS_PASV,
'default' => true,
)),
)),
)
),

array(
'type' => 'fieldset',
'childs' => array(
new fieldCheckbox('is_skip', array(
'title' => LANG_CP_FTP_SKIP,
'hint' => LANG_CP_FTP_SKIP_HINT,
'default' => false
))
)
)
)

);

Expand Down
94 changes: 93 additions & 1 deletion system/controllers/content/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function getDefaultContentFieldOptions(){
public function addContentField($ctype_name, $field, $is_virtual=false){

$content_table_name = $this->table_prefix . $ctype_name;
$fields_table_name = $this->table_prefix . $ctype_name . '_fields';
$fields_table_name = $this->table_prefix . $ctype_name . '_fields';

$field['ordering'] = $this->getNextOrdering($fields_table_name);

Expand All @@ -399,6 +399,29 @@ public function addContentField($ctype_name, $field, $is_virtual=false){

$id = $this->insert($fields_table_name, $field);

// если есть опция полнотекстового поиска
if(!$is_virtual && is_array($field['options']) && !empty($field['options']['in_fulltext_search'])){
// получаем полнотекстовый индекс для таблицы, он может быть только один
$fulltext_index = $this->db->getTableIndexes($content_table_name, 'FULLTEXT');
if($fulltext_index){
// название индекса
$index_name = key($fulltext_index);
// поля индекса
$index_fields = $fulltext_index[$index_name];
// ищем, нет ли такого поля уже в индексе, мало ли :-)
$key = array_search($field['name'], $index_fields);
// не нашли, добавляем
if($key === false){
// удаляем старый индекс
$this->db->dropIndex($content_table_name, $index_name);
// создаем новый
$this->createFullTextIndex($ctype_name, $field['name']);
}
} else {
$this->createFullTextIndex($ctype_name, $field['name']);
}
}

return $id;

}
Expand Down Expand Up @@ -575,12 +598,81 @@ public function updateContentField($ctype_name, $id, $field){
$this->db->dropIndex($content_table_name, $field_old['name']);
}

// если есть опция полнотекстового поиска и ее значение изменилось
if(is_array($field['options']) && array_key_exists('in_fulltext_search', $field['options'])){
if($field['options']['in_fulltext_search'] != @$field_old['options']['in_fulltext_search']){
// получаем полнотекстовый индекс для таблицы, он может быть только один
$fulltext_index = $this->db->getTableIndexes($content_table_name, 'FULLTEXT');
if($fulltext_index){
// название индекса
$index_name = key($fulltext_index);
// поля индекса
$index_fields = $fulltext_index[$index_name];
// выключили опцию
if(!$field['options']['in_fulltext_search']){
$key = array_search($field['name'], $index_fields);
// нашли - удаляем из массива
if($key !== false){
unset($index_fields[$key]);
// удаляем индекс
$this->db->dropIndex($content_table_name, $index_name);
// и создаем новый
if($index_fields){
$this->db->addIndex($content_table_name, $index_fields, '', 'FULLTEXT');
}
}
}
// включили опцию
if($field['options']['in_fulltext_search']){
// ищем, нет ли такого поля уже в индексе, мало ли :-)
$key = array_search($field['name'], $index_fields);
// не нашли, добавляем
if($key === false){
// удаляем старый индекс
$this->db->dropIndex($content_table_name, $index_name);
// создаем новый
$this->createFullTextIndex($ctype_name, $field['name']);
}
}

}
}
}

}

return $this->update($fields_table_name, $id, $field);

}

/**
* Создает fulltext индекс согласно настроек полей типа контента
* @param string $ctype_name Название типа контента
* @param string|null $add_field Название поля, для которого принудительно нужно создать индекс
* @return boolean
*/
public function createFullTextIndex($ctype_name, $add_field=null) {

// важен порядок индексов, поэтому создаем их так, как они будут в запросе
// для этого получаем все поля этого типа контента
$fields = $this->getContentFields($ctype_name);

foreach ($fields as $field) {

$is_text = in_array($field['type'], array('caption', 'text', 'html')) && ($field['handler']->getOption('in_fulltext_search') || $field['name'] == $add_field);
if(!$is_text){ continue; }

$index_fields[] = $field['name'];

}

if($index_fields){
$this->db->addIndex($this->table_prefix . $ctype_name, $index_fields, '', 'FULLTEXT'); return true;
}

return false;

}
//============================================================================//
//============================================================================//

Expand Down
Loading

0 comments on commit c1354de

Please sign in to comment.