Skip to content

Commit

Permalink
Исправлены проблемы с фильтрами для типов контента по умолчанию,
Browse files Browse the repository at this point in the history
Исправлены некоторые ошибки, добавлены шаблоны компонента редиректы
close #1254
close #1253
  • Loading branch information
fuzegit committed Oct 26, 2020
1 parent 8b7eca9 commit 411849c
Show file tree
Hide file tree
Showing 32 changed files with 256 additions and 66 deletions.
1 change: 1 addition & 0 deletions system/controllers/admin/forms/form_ctypes_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function init($do, $ctype_name) {
)),
new fieldString('hint', array(
'title' => LANG_CP_FIELD_HINT,
'is_clean_disable' => true,
'rules' => array(
array('max_length', 255)
)
Expand Down
2 changes: 1 addition & 1 deletion system/controllers/admin/forms/form_ctypes_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function init($do, $ctype, $fields, $props_fields, $table_name, $filter)
'childs' => array(
new fieldString('slug', array(
'title' => LANG_SYSTEM_NAME,
'prefix' => '/'.$ctype['name'].'/',
'prefix' => href_to(((cmsConfig::get('ctype_default') && in_array($ctype['name'], cmsConfig::get('ctype_default'))) ? '' : $ctype['name'])),
'options'=>array(
'max_length' => 100,
'show_symbol_count' => true
Expand Down
5 changes: 3 additions & 2 deletions system/controllers/admin/forms/form_ctypes_relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ public function init($do, $ctype_id) {
$list = ['0' => ''];
$ctype_id = is_array($item) ? array_value_recursive('child_ctype_id', $item) : false;
if (!$ctype_id && $request) {
$ctype_id = $request->get('child_ctype_id', 0);
$ctype_id = $request->get('child_ctype_id', '');
}
if (!$ctype_id) {
return $list;
}
$datasets = $content_model->getContentDatasets($ctype_id);
list($target, $id) = explode(':', $ctype_id);
$datasets = $content_model->getContentDatasets($id ? $id : $target);
if ($datasets) {
$list = $list + array_collection_to_list($datasets, 'id', 'title');
}
Expand Down
2 changes: 1 addition & 1 deletion system/controllers/admin/grids/grid_ctype_filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function grid_ctype_filters($controller, $ctype = []){
array(
'title' => LANG_VIEW,
'class' => 'view',
'href' => href_to($ctype['name'], '{slug}')
'href' => href_to(((cmsConfig::get('ctype_default') && in_array($ctype['name'], cmsConfig::get('ctype_default'))) ? '' : $ctype['name']), '{slug}')
),
array(
'title' => LANG_EDIT,
Expand Down
14 changes: 11 additions & 3 deletions system/controllers/content/actions/category_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ public function run() {

if (empty($ctype['options']['list_off_breadcrumb'])) {

if ($ctype['options']['list_on'] && !$is_frontpage && !empty($base_url)) {
if ($ctype['options']['list_on'] && !$is_frontpage) {
$this->cms_template->addBreadcrumb($list_header, href_to($ctype['name']));
}

if (isset($category['path']) && $category['path']) {
if (!empty($category['path'])) {
foreach ($category['path'] as $c) {
$this->cms_template->addBreadcrumb($c['title'], href_to($base_url, $c['slug']));
}
Expand Down Expand Up @@ -494,7 +494,15 @@ private function getCategoryAndSlugAndCtype() {
!$this->request->get('dataset', '') &&
$this->cms_config->ctype_default &&
in_array($ctype['name'], $this->cms_config->ctype_default))) {
$this->redirect(href_to($category['slug']), 301);
if(!empty($category['slug'])){
if(!empty($this->list_filter['slug'])){
$this->redirect(href_to($category['slug'], $this->list_filter['slug']), 301);
}
$this->redirect(href_to($category['slug']), 301);
}
if(!empty($this->list_filter['slug'])){
$this->redirect(href_to($this->list_filter['slug']), 301);
}
}

// если тип контента сменился
Expand Down
40 changes: 0 additions & 40 deletions system/controllers/content/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1265,46 +1265,6 @@ public function bindItemToParents($ctype, $item, $parents = false){

}

public function prepareItemSeo($item, $fields, $ctype) {

list($ctype, $fields, $item) = cmsEventsManager::hook('prepare_item_seo', array($ctype, $fields, $item));

$_item = $item;

foreach ($fields as $field) {

if (!isset($item[$field['name']])) { $_item[$field['name']] = null; continue; }

if (empty($item[$field['name']]) && $item[$field['name']] !== '0') {
$_item[$field['name']] = null; continue;
}

if(isset($field['string_value'])){
$_item[$field['name']] = strip_tags($field['string_value']);
} else {
$_item[$field['name']] = strip_tags($field['handler']->setItem($item)->getStringValue($item[$field['name']]));
}

}

if(!empty($item['tags']) && is_array($item['tags'])){
$_item['tags'] = implode(', ', $item['tags']);
}

if(!isset($item['category']) && !empty($item['category_id'])){
$item['category'] = $this->model->getCategory($ctype['name'], $item['category_id']);
}

if(!empty($item['category']['title'])){
$_item['category'] = $item['category']['title'];
} else {
$_item['category'] = null;
}

return $_item;

}

public function applyCategorySeo($ctype, $category, $dataset, $add_meta_item = []) {

// паттерны
Expand Down
5 changes: 5 additions & 0 deletions system/controllers/users/actions/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ public function run($profile = null){
$fields[$name]['string_value'] = $field['handler']->getStringValue($profile[$name]);
}

// Формируем метатеги
$meta_profile = $this->prepareItemSeo($profile, $fields, ['name' => 'users']);

// Доступность профиля для данного пользователя
if ( !$this->cms_user->isPrivacyAllowed($profile, 'users_profile_view') ){
return $this->cms_template->render('profile_closed', array(
'profile' => $profile,
'meta_profile' => $meta_profile,
'sys_fields' => $sys_fields,
'fields' => $fields,
'user' => $this->cms_user,
Expand Down Expand Up @@ -77,6 +81,7 @@ public function run($profile = null){

return $this->cms_template->render('profile_view', array(
'options' => $this->options,
'meta_profile' => $meta_profile,
'profile' => $profile,
'user' => $this->cms_user,
'is_own_profile' => $this->is_own_profile,
Expand Down
3 changes: 3 additions & 0 deletions system/controllers/users/actions/profile_friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public function run($profile){
// Получаем поля
$fields = $this->model_content->setTablePrefix('')->orderBy('ordering')->getContentFields('{users}');

$meta_profile = $this->prepareItemSeo($profile, $fields, ['name' => 'users']);

return $this->cms_template->render('profile_friends', array(
'user' => $this->cms_user,
'meta_profile' => $meta_profile,
'tabs' => $tabs,
'fields' => $fields,
'tab' => $this->tabs['friends'],
Expand Down
3 changes: 3 additions & 0 deletions system/controllers/users/actions/profile_karma.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public function run($profile){

$fields = $this->model_content->setTablePrefix('')->orderBy('ordering')->getContentFields('{users}');

$meta_profile = $this->prepareItemSeo($profile, $fields, ['name' => 'users']);

$this->cms_template->render('profile_karma', array(
'user' => $this->cms_user,
'meta_profile' => $meta_profile,
'tabs' => $tabs,
'fields' => $fields,
'tab' => $this->tabs['karma'],
Expand Down
8 changes: 8 additions & 0 deletions system/controllers/users/actions/profile_tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ public function run($profile, $tab_name, $dataset = false){
// Получаем поля
$fields = $this->model_content->setTablePrefix('')->orderBy('ordering')->getContentFields('{users}');

// Парсим значения полей
foreach($fields as $name => $field){
$fields[$name]['string_value'] = $field['handler']->setItem($profile)->getStringValue($profile[$name]);
}

$meta_profile = $this->prepareItemSeo($profile, $fields, ['name' => 'users']);

$this->cms_template->render('profile_tab', array(
'tabs' => $tabs_menu,
'meta_profile' => $meta_profile,
'fields' => $fields,
'tab' => $tab,
'profile' => $profile,
Expand Down
1 change: 1 addition & 0 deletions system/controllers/users/backend/forms/form_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function init($do) {
)),
new fieldString('hint', array(
'title' => LANG_CP_FIELD_HINT,
'is_clean_disable' => true,
'rules' => array(
array('max_length', 255)
)
Expand Down
39 changes: 39 additions & 0 deletions system/core/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,45 @@ public function getUniqueKey($params) {
return implode('.', $params);
}

public function prepareItemSeo($item, $fields, $ctype) {

list($ctype, $fields, $item) = cmsEventsManager::hook(['prepare_item_seo', 'prepare_item_'.$ctype['name'].'_seo'], [$ctype, $fields, $item]);

$_item = $item;

foreach ($fields as $field) {

if (!isset($item[$field['name']])) { $_item[$field['name']] = null; continue; }

if (empty($item[$field['name']]) && $item[$field['name']] !== '0') {
$_item[$field['name']] = null; continue;
}

if(isset($field['string_value'])){
$_item[$field['name']] = strip_tags($field['string_value']);
} else {
$_item[$field['name']] = strip_tags($field['handler']->setItem($item)->getStringValue($item[$field['name']]));
}

}

if(!empty($item['tags']) && is_array($item['tags'])){
$_item['tags'] = implode(', ', $item['tags']);
}

if(!isset($item['category']) && !empty($item['category_id'])){
$item['category'] = $this->model->getCategory($ctype['name'], $item['category_id']);
}

if(!empty($item['category']['title'])){
$_item['category'] = $item['category']['title'];
} else {
$_item['category'] = null;
}

return $_item;
}

//============================================================================//
//============================================================================//

Expand Down
4 changes: 2 additions & 2 deletions system/languages/ru/controllers/redirect/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

define('LANG_REDIRECT_CONTROLLER', 'Редиректы');
define('LANG_REDIRECT_H1', 'Переход по внешней ссылке');
define('LANG_REDIRECT_HINT1', 'Вы покидаете сайт "<a href="%s">%s</a>" по внешней ссылке <a rel="nofollow" href="%s">%s</a>.');
define('LANG_REDIRECT_HINT1', 'Вы покидаете сайт «<a href="%s">%s</a>» по внешней ссылке <a rel="nofollow" href="%s">%s</a>.');
define('LANG_REDIRECT_HINT2', 'Мы не несем ответственности за содержимое сайта <b>%s</b> и настоятельно рекомендуем <b>не указывать</b> никаких своих личных данных на сторонних сайтах.');
define('LANG_REDIRECT_HINT3', 'Если Вы не хотите рисковать безопасностью компьютера, нажмите <a rel="nofollow" href="javascript:window.close()">отмена</a>, иначе вы будете перемещены через');
define('LANG_REDIRECT_HINT4', 'Не предупреждать меня больше');
define('LANG_REDIRECT_YOUR_SAFETY', '"%s" всегда заботится о вашей безопасности.');
define('LANG_REDIRECT_YOUR_SAFETY', '«%s» всегда заботится о вашей безопасности.');
define('LANG_REDIRECT_SUSPICIOUS_LINK', 'Ссылка на подозрительный сайт');
define('LANG_REDIRECT_SUSPICIOUS_LINK_1', 'Ссылка, по которой Вы попытались перейти, может вести на сайт, который был создан с целью обмана пользователей и получения за счет этого прибыли. <a rel="nofollow" href="javascript:window.close()">Закрыть вкладку</a>');
define('LANG_REDIRECT_SUSPICIOUS_LINK_2', 'Я понял риск, но все равно хочу <a rel="nofollow" href="%s">перейти на сайт</a>.');
Expand Down
2 changes: 1 addition & 1 deletion templates/admincoreui/controllers/admin/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ th[rel="dg_actions"] {
background-size: 20px;
content: '';
display: block;
left: -20px;
left: calc(100% - 20px);
position: absolute;
top: 0.75rem;
opacity: 0;
Expand Down
2 changes: 1 addition & 1 deletion templates/default/controllers/redirect/index.tpl.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--noindex-->
<?php if(!$is_domain_banned){ ?>

<?php $this->addTplJSName('jquery-cookie');; ?>
<?php $this->addTplJSName('jquery-cookie'); ?>

<?php if($user->is_logged){ ?>
<div class="accept_redirect">
Expand Down
2 changes: 1 addition & 1 deletion templates/default/controllers/users/profile_closed.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
?>

<div id="user_profile_header">
<?php $this->renderChild('profile_header', array('profile'=>$profile, 'tabs'=>false, 'is_can_view'=>false)); ?>
<?php $this->renderChild('profile_header', ['profile'=>$profile, 'meta_profile' => $meta_profile, 'tabs'=>false, 'is_can_view'=>false]); ?>
</div>

<div id="user_profile">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
?>

<div id="user_profile_header">
<?php $this->renderChild('profile_header', array('profile'=>$profile, 'tabs'=>$tabs)); ?>
<?php $this->renderChild('profile_header', ['profile'=>$profile, 'meta_profile' => $meta_profile, 'tabs'=>$tabs]); ?>
</div>

<div id="user_content_list"><?php echo $profiles_list_html; ?></div>
2 changes: 1 addition & 1 deletion templates/default/controllers/users/profile_karma.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
?>

<div id="user_profile_header">
<?php $this->renderChild('profile_header', array('profile'=>$profile, 'tabs'=>$tabs)); ?>
<?php $this->renderChild('profile_header', ['profile'=>$profile, 'meta_profile' => $meta_profile, 'tabs'=>$tabs]); ?>
</div>

<div id="users_karma_log_window">
Expand Down
2 changes: 1 addition & 1 deletion templates/default/controllers/users/profile_tab.tpl.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php $this->setPageDescription($profile['nickname'].' — '.$tab['title']); ?>
<div id="user_profile_header">
<?php $this->renderChild('profile_header', array('profile'=>$profile, 'tabs'=>$tabs)); ?>
<?php $this->renderChild('profile_header', ['profile'=>$profile, 'meta_profile' => $meta_profile, 'tabs'=>$tabs]); ?>
</div>

<div id="user_profile_tab_content">
Expand Down
2 changes: 1 addition & 1 deletion templates/default/controllers/users/profile_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
?>

<div id="user_profile_header">
<?php $this->renderChild('profile_header', array('profile'=>$profile, 'tabs'=>$tabs)); ?>
<?php $this->renderChild('profile_header', ['profile'=>$profile, 'meta_profile' => $meta_profile, 'tabs'=>$tabs]); ?>
</div>

<div id="user_profile">
Expand Down
42 changes: 42 additions & 0 deletions templates/modern/controllers/content/category_form.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

$page_title = $do=='add' ?
$ctype['title'] . ': <span class="text-muted">' . LANG_ADD_CATEGORY . '</span>':
$ctype['title'] . ': <span class="text-muted">' . LANG_EDIT_CATEGORY . '</span>';

$this->setPageTitle($do=='add' ? LANG_ADD_CATEGORY : LANG_EDIT_CATEGORY);

if ($ctype['options']['list_on']){
$this->addBreadcrumb($ctype['title'], href_to($ctype['name']));
}

$this->addBreadcrumb($do=='add' ? LANG_ADD_CATEGORY : LANG_EDIT_CATEGORY);

$this->addToolButton(array(
'class' => 'save',
'icon' => 'save',
'title' => LANG_SAVE,
'href' => "javascript:icms.forms.submit()"
));

$this->addToolButton(array(
'class' => 'cancel',
'icon' => 'window-close',
'title' => LANG_CANCEL,
'href' => $back_url ? $back_url : href_to($ctype['name'])
));

?>

<h1><?php echo $page_title ?></h1>

<?php

$category['ctype_name'] = $ctype['name'];

$this->renderForm($form, $category, array(
'action' => '',
'cancel' => array('show' => true, 'href' => $back_url ? $back_url : href_to($ctype['name'])),
'method' => 'post',
'toolbar' => false
), $errors);
35 changes: 35 additions & 0 deletions templates/modern/controllers/content/folder_form.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

$this->setPageTitle(LANG_EDIT_FOLDER);

if ($ctype['options']['list_on']){
$this->addBreadcrumb($ctype['title'], href_to($ctype['name']));
}

$this->addBreadcrumb(LANG_EDIT_CATEGORY);

$this->addToolButton(array(
'class' => 'save',
'icon' => 'save',
'title' => LANG_SAVE,
'href' => "javascript:icms.forms.submit()"
));

$this->addToolButton(array(
'class' => 'cancel',
'icon' => 'window-close',
'title' => LANG_CANCEL,
'href' => href_to($ctype['name'])
));

?>

<h1><?php echo LANG_EDIT_FOLDER; ?></h1>

<?php

$this->renderForm($form, $folder, array(
'action' => '',
'method' => 'post',
'toolbar' => false
), $errors);
Loading

0 comments on commit 411849c

Please sign in to comment.