From 5cf54d07d28cdf0c91ea7a4f7d5e59de601d8fb2 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 2 Dec 2019 13:32:21 -0800 Subject: [PATCH] Basic per-item search engine robots handling added to News and Pages. --- e107_admin/cpage.php | 9 ++++++++- e107_admin/newspost.php | 8 ++++++++ e107_core/sql/core_sql.php | 2 ++ e107_handlers/admin_ui.php | 7 +++++++ e107_handlers/application.php | 13 +++++++++++++ e107_handlers/form_handler.php | 10 ++++++++++ e107_languages/English/admin/lan_admin.php | 6 ++++++ e107_plugins/news/news.php | 6 ++++++ .../js/bootstrap-multiselect.js | 2 +- e107_web/js/core/admin.jquery.js | 15 ++++++++++++++- page.php | 5 +++++ 11 files changed, 80 insertions(+), 3 deletions(-) diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index 073d58ea4..cc933bb0e 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -596,7 +596,8 @@ class page_admin_ui extends e_admin_ui 'page_sef' => array('title'=> LAN_SEFURL, 'tab' => 1, 'type' => 'text', 'batch'=>true, 'data'=>'str', 'inline'=>true, 'width' => 'auto', 'writeParms'=>'size=xxlarge&sef=page_title'), 'page_metakeys' => array('title'=> LAN_KEYWORDS, 'tab' => 1, 'type' => 'tags', 'data'=>'str', 'width' => 'auto'), 'page_metadscr' => array('title'=> CUSLAN_11, 'tab' => 1, 'type' => 'text', 'data'=>'str', 'width' => 'auto', 'writeParms'=>'size=xxlarge'), - + 'page_metarobots' => array('title' => LAN_ROBOTS, 'tab'=>1, 'type' => 'dropdown', 'data'=>'safestr', 'batch'=>true, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true), + 'page_order' => array('title'=> LAN_ORDER, 'tab' => 1, 'type' => 'number', 'width' => 'auto', 'inline'=>true), 'page_fields' => array('title'=>'Custom Fields', 'tab'=>4, 'type'=>'hidden', 'data'=>'json', 'width'=>'auto'), @@ -641,6 +642,12 @@ class page_admin_ui extends e_admin_ui function init() { + $this->fields['page_metarobots']['writeParms']['optArray'] = e107::getSingleton('eResponse')->getRobotTypes(); + $this->fields['page_metarobots']['writeParms']['title'] = e107::getSingleton('eResponse')->getRobotDescriptions(); + $this->fields['page_metarobots']['writeParms']['multiple'] = 1; + + + $mode = $this->getMode(); $this->perPage = (int) e107::pref('core','admin_page_perpage', 10); diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 33b64dd37..961424aa7 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -459,6 +459,8 @@ class news_admin_ui extends e_admin_ui 'news_meta_keywords' => array('title' => LAN_KEYWORDS, 'type' => 'tags', 'data'=>'safestr', 'filter'=>true, 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'safestr','filter'=>true, 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge')), + 'news_meta_robots' => array('title' => LAN_ROBOTS, 'type' => 'dropdown', 'data'=>'safestr', 'tab'=>1, 'inline'=>true, 'readParms'=>array('type'=>'checkboxes'), 'writeParms'=>array('multiple'=>1), 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false, 'batch'=>true, 'filter'=>true), + 'news_sef' => array('title' => LAN_SEFURL, 'type' => 'text', 'batch'=>1, 'data'=>'str', 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title')), 'news_ping' => array('title' => LAN_PING, 'type' => 'checkbox', 'tab'=>1, 'data'=>false, 'writeParms'=>'value=0', 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), @@ -775,6 +777,7 @@ class news_admin_ui extends e_admin_ui 'news_sef' , 'news_meta_keywords', 'news_meta_description' , + 'news_meta_robots' , 'news_ping', 'news_email_notify', @@ -923,6 +926,11 @@ class news_admin_ui extends e_admin_ui $this->fields['news_category']['writeParms']['size'] = 'xlarge'; $this->fields['news_render_type']['writeParms']['optArray'] = $this->news_renderTypes; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox"); $this->fields['news_render_type']['writeParms']['multiple'] = 1; + + $this->fields['news_meta_robots']['writeParms']['optArray'] = e107::getSingleton('eResponse')->getRobotTypes(); + $this->fields['news_meta_robots']['writeParms']['title'] = e107::getSingleton('eResponse')->getRobotDescriptions(); + $this->fields['news_meta_robots']['writeParms']['multiple'] = 1; + //$this->fields['news_meta_robots']['writeParms']['default'] = 'blank'; // $this->newspost = new admin_newspost; // $this->newspost->news_renderTypes = $this->news_renderTypes; // $this->newspost->observer(); diff --git a/e107_core/sql/core_sql.php b/e107_core/sql/core_sql.php index c370068fd..b1a1ce578 100755 --- a/e107_core/sql/core_sql.php +++ b/e107_core/sql/core_sql.php @@ -306,6 +306,7 @@ CREATE TABLE news ( news_extended longtext NOT NULL, news_meta_keywords varchar(255) NOT NULL default '', news_meta_description text NOT NULL, + news_meta_robots varchar(255) NOT NULL default '', news_datestamp int(10) unsigned NOT NULL default '0', news_author int(10) unsigned NOT NULL default '0', news_category tinyint(3) unsigned NOT NULL default '0', @@ -381,6 +382,7 @@ CREATE TABLE page ( page_chapter int(10) unsigned NOT NULL default '0', page_metakeys varchar (250) NOT NULL default '', page_metadscr mediumtext, + page_metarobots varchar (250) NOT NULL default '', page_text mediumtext, page_author int(10) unsigned NOT NULL default '0', page_datestamp int(10) unsigned NOT NULL default '0', diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 4277a42c5..eb6cb0eb3 100755 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -7383,6 +7383,13 @@ class e_admin_form_ui extends e_form $parms = vartrue($val['writeParms'], array()); if(is_string($parms)) parse_str($parms, $parms); + //Basic batch support for dropdown with multiple values. (comma separated) + if(!empty($val['writeParms']['multiple']) && $val['type'] === 'dropdown' && !empty($val['writeParms']['optArray'])) + { + $val['type'] = 'comma'; + $parms = $val['writeParms']['optArray']; + } + switch($val['type']) { diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 452cbf719..56e0274df 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -3961,6 +3961,8 @@ class eResponse protected $_meta_name_only = array('keywords', 'viewport', 'robots'); // Keep FB happy. protected $_meta_property_only = array('article:section', 'article:tag'); // Keep FB happy. protected $_meta = array(); + protected $_meta_robot_types = array('noindex'=>'NoIndex', 'nofollow'=>'NoFollow','noarchive'=>'NoArchive','noimageindex'=>'NoImageIndex' ); + protected $_meta_robot_descriptions = array('noindex'=>LAN_ROBOTS_NOINDEX, 'nofollow'=>LAN_ROBOTS_NOFOLLOW,'noarchive'=>LAN_ROBOTS_NOARCHIVE,'noimageindex'=>LAN_ROBOTS_NOIMAGE ); protected $_title_separator = ' » '; protected $_content_type = 'html'; protected $_content_type_arr = array( @@ -3980,6 +3982,16 @@ class eResponse 'jsonRender' => false, ); + public function getRobotTypes() + { + return $this->_meta_robot_types; + } + + public function getRobotDescriptions() + { + return $this->_meta_robot_descriptions; + } + public function setParam($key, $value) { $this->_params[$key] = $value; @@ -4368,6 +4380,7 @@ class eResponse e107::getDebug()->log($this->_meta); + foreach ($this->_meta as $attr) { $attrData .= 'select_open($name, $options)."\n"; @@ -3316,6 +3317,15 @@ var_dump($select_options);*/ $opts['disabled'] = in_array($value, $options['optDisabled']); } + if(is_array($options['title']) && !empty($options['title'][$value])) + { + $opts['data-title'] = $options['title'][$value]; + } + else + { + $opts['data-title'] = ''; + } + $text .= $this->option($label, $value, $sel, $opts)."\n"; } } diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index 9bb19397d..dc3a8bba3 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -569,4 +569,10 @@ define("LAN_DOWNLOAD_COMPLETE", "Download Complete!"); define("LAN_UI_FILTER_SEARCH_IN_FIELD", "Search in Field"); +define("LAN_ROBOTS", "Robots"); +define("LAN_ROBOTS_NOINDEX", "Prevent search engines from indexing this item."); +define("LAN_ROBOTS_NOFOLLOW", "Prevent search engines from following links in this item."); +define("LAN_ROBOTS_NOARCHIVE", "Prevent cached copies of this item from appearing in search results."); +define("LAN_ROBOTS_NOIMAGE", "Prevent search engines from indexing images of this item."); + diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index aa2168335..51f72c23b 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -607,6 +607,12 @@ class news_front if($type == 'news') { + + if(!empty($news['news_meta_robots'])) + { + e107::meta('robots', $news['news_meta_robots']); + } + if($news['news_title'] && !defined('e_PAGETITLE')) { define('e_PAGETITLE', $news['news_title']); diff --git a/e107_web/js/bootstrap-multiselect/js/bootstrap-multiselect.js b/e107_web/js/bootstrap-multiselect/js/bootstrap-multiselect.js index 15eb9a810..c4b46f752 100644 --- a/e107_web/js/bootstrap-multiselect/js/bootstrap-multiselect.js +++ b/e107_web/js/bootstrap-multiselect/js/bootstrap-multiselect.js @@ -88,7 +88,7 @@ $(element).prop('selected', 'selected'); } - $('ul', this.container).append('
  • '); + $('ul', this.container).append('
  • '); var selected = $(element).prop('selected') || false; var checkbox = $('ul li input[value="' + $(element).val() + '"]', this.container); diff --git a/e107_web/js/core/admin.jquery.js b/e107_web/js/core/admin.jquery.js index 61d0b213e..125df9331 100644 --- a/e107_web/js/core/admin.jquery.js +++ b/e107_web/js/core/admin.jquery.js @@ -95,13 +95,21 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}}; placement = 'top'; } + // custom position defined in field-help container class var custPlace = $fieldHelp.attr('data-placement'); // ie top|left|bottom|right - if(custPlace !== undefined) { placement = custPlace; } + // custom position defined in selector tag. + var pos = $(this).attr('data-tooltip-position'); + if(pos !== undefined) + { + placement = pos; + } + + $fieldHelp.hide(); $this.tooltip({ @@ -568,6 +576,11 @@ $(document).ready(function() $(this).multiselect({ buttonClass: 'btn btn-default'} ); } + + /* optionLabel: function(element) { + return $(element).html() + '(' + $(element).val() + ')'; + }*/ + }); diff --git a/page.php b/page.php index 6f4849fd7..90e173bb5 100644 --- a/page.php +++ b/page.php @@ -700,6 +700,11 @@ class pageClass e107::meta('keywords', eHelper::formatMetaKeys($this->page['page_metakeys'])); } + if(!empty($this->page['page_metarobots'])) + { + e107::meta('robots', $this->page['page_metarobots']); + } + $tp = e107::getParser(); if($tp->isImage($this->page['menu_image']))