From faf4b1ea543c864790c3464a9926072728b51d08 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 8 May 2016 23:23:27 +0900 Subject: [PATCH] Use global keywords and description if a module does not have its own SEO info --- classes/module/ModuleHandler.class.php | 19 +++++++++++++++ modules/admin/admin.admin.controller.php | 18 ++++++++++++++ modules/admin/admin.admin.view.php | 15 ++++++++++++ modules/admin/conf/module.xml | 2 ++ modules/admin/lang/en.php | 5 ++++ modules/admin/lang/ko.php | 5 ++++ modules/admin/tpl/config_header.html | 1 + modules/admin/tpl/config_seo.html | 30 ++++++++++++++++++++++++ 8 files changed, 95 insertions(+) create mode 100644 modules/admin/tpl/config_seo.html diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index feb4f3006..df07ebdf7 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -295,6 +295,25 @@ class ModuleHandler extends Handler Context::setBrowserTitle(Context::getSiteTitle()); Context::addBrowserTitle($module_info->browser_title); } + + $module_config = $oModuleModel->getModuleConfig('module'); + if ($module_info->meta_keywords) + { + Context::addMetaTag('keywords', escape($module_info->meta_keywords)); + } + elseif($module_config->meta_keywords) + { + Context::addMetaTag('keywords', escape($module_config->meta_keywords)); + } + + if ($module_info->meta_description) + { + Context::addMetaTag('description', escape($module_info->meta_description)); + } + elseif($module_config->meta_description) + { + Context::addMetaTag('description', escape($module_config->meta_description)); + } $viewType = (Mobile::isFromMobilePhone()) ? 'M' : 'P'; $targetSrl = (Mobile::isFromMobilePhone()) ? 'mlayout_srl' : 'layout_srl'; diff --git a/modules/admin/admin.admin.controller.php b/modules/admin/admin.admin.controller.php index 11acf589e..87441ee69 100644 --- a/modules/admin/admin.admin.controller.php +++ b/modules/admin/admin.admin.controller.php @@ -771,6 +771,24 @@ class adminAdminController extends admin $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigDebug')); } + /** + * Update SEO configuration. + */ + function procAdminUpdateSEO() + { + $vars = Context::getRequestVars(); + + $args = new stdClass; + $args->meta_keywords = $vars->site_meta_keywords ? implode(', ', array_map('trim', explode(',', $vars->site_meta_keywords))) : ''; + $args->meta_description = trim(utf8_normalize_spaces($vars->site_meta_description)); + + $oModuleController = getController('module'); + $oModuleController->updateModuleConfig('module', $args); + + $this->setMessage('success_updated'); + $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSEO')); + } + /** * Update sitelock configuration. */ diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 538af0cd2..3246d327c 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -564,6 +564,21 @@ class adminAdminView extends admin $this->setTemplateFile('config_debug'); } + /** + * Display Debug Settings page + * @return void + */ + function dispAdminConfigSEO() + { + // Site title and HTML footer + $oModuleModel = getModel('module'); + $config = $oModuleModel->getModuleConfig('module'); + Context::set('site_meta_keywords', escape($config->meta_keywords)); + Context::set('site_meta_description', escape($config->meta_description)); + + $this->setTemplateFile('config_seo'); + } + /** * Display Sitelock Settings page * @return void diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index 0c51c531e..b6fd159a4 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -8,6 +8,7 @@ + @@ -26,6 +27,7 @@ + diff --git a/modules/admin/lang/en.php b/modules/admin/lang/en.php index d7a99bc5c..61db45e17 100644 --- a/modules/admin/lang/en.php +++ b/modules/admin/lang/en.php @@ -5,6 +5,7 @@ $lang->subtitle_primary = 'General Settings'; $lang->subtitle_security = 'Security Settings'; $lang->subtitle_advanced = 'Advanced Settings'; $lang->subtitle_debug = 'Debug Settings'; +$lang->subtitle_seo = 'SEO Settings'; $lang->subtitle_etc = 'Other Settings'; $lang->current_state = 'Current state'; $lang->latest_documents = 'Latest Documents'; @@ -142,6 +143,10 @@ $lang->debug_log_filename = 'Log filename'; $lang->about_debug_log_filename = 'YYYYMMDD in the filename will be replaced with the current date.
It is recommended to split the log file by date to prevent it from getting too large.'; $lang->msg_debug_log_filename_not_writable = 'Rhymix cannot write log files in the specified path.'; $lang->debug_allowed_ip = 'Allowed IP addresses'; +$lang->site_meta_keywords = 'SEO Keywords'; +$lang->about_site_meta_keywords = 'These keywords will be used on pages that do not have their own keywords.'; +$lang->site_meta_description = 'SEO Description'; +$lang->about_site_meta_description = 'This description will be used on pages that do not have their own description.'; $lang->autoinstall = 'EasyInstall'; $lang->last_week = 'Last Week'; $lang->this_week = 'This Week'; diff --git a/modules/admin/lang/ko.php b/modules/admin/lang/ko.php index 5f20eddb2..30cae27cd 100644 --- a/modules/admin/lang/ko.php +++ b/modules/admin/lang/ko.php @@ -5,6 +5,7 @@ $lang->subtitle_primary = '기본 설정'; $lang->subtitle_security = '보안 설정'; $lang->subtitle_advanced = '고급 설정'; $lang->subtitle_debug = '디버그 설정'; +$lang->subtitle_seo = 'SEO 설정'; $lang->subtitle_etc = '기타'; $lang->current_state = '현황'; $lang->latest_documents = '최근 글'; @@ -145,6 +146,10 @@ $lang->debug_log_filename = '디버그 정보 기록 파일'; $lang->about_debug_log_filename = '파일명에 YYYYMMDD가 포함된 경우 날짜별로 파일을 분리하여 기록합니다.
파일을 분리하지 않으면 용량이 매우 커질 수 있으니 주의하십시오.'; $lang->msg_debug_log_filename_not_writable = '지정한 경로에 로그 파일을 작성할 수 없습니다.'; $lang->debug_allowed_ip = '디버그 허용 IP'; +$lang->site_meta_keywords = 'SEO 키워드'; +$lang->about_site_meta_keywords = '별도의 키워드를 지정하지 않은 페이지에서는 이 키워드 목록이 표시됩니다.'; +$lang->site_meta_description = 'SEO 설명'; +$lang->about_site_meta_description = '별도의 설명을 지정하지 않은 페이지에서는 이 설명이 표시됩니다.'; $lang->autoinstall = '쉬운 설치'; $lang->last_week = '지난주'; $lang->this_week = '이번주'; diff --git a/modules/admin/tpl/config_header.html b/modules/admin/tpl/config_header.html index 38b456bc5..dabe0f771 100644 --- a/modules/admin/tpl/config_header.html +++ b/modules/admin/tpl/config_header.html @@ -8,5 +8,6 @@
  • {$lang->subtitle_security}
  • {$lang->subtitle_advanced}
  • {$lang->subtitle_debug}
  • +
  • {$lang->subtitle_seo}
  • {$lang->subtitle_sitelock}
  • diff --git a/modules/admin/tpl/config_seo.html b/modules/admin/tpl/config_seo.html new file mode 100644 index 000000000..886c01cd4 --- /dev/null +++ b/modules/admin/tpl/config_seo.html @@ -0,0 +1,30 @@ + +
    +

    {$XE_VALIDATOR_MESSAGE}

    +
    +
    +
    + + + +
    + +
    + +

    {$lang->about_site_meta_keywords}

    +
    +
    +
    + +
    + +

    {$lang->about_site_meta_description}

    +
    +
    +
    +
    + +
    +
    +
    +