mirror of
https://github.com/e107inc/e107.git
synced 2025-10-22 18:26:19 +02:00
Issue #4783 Added new field for meta-news-title. New prefs added for SEO Title and Description character limits.
This commit is contained in:
@@ -39,7 +39,8 @@ class meta_admin extends e_admin_dispatcher
|
||||
|
||||
|
||||
protected $adminMenu = array(
|
||||
'main/meta' => array('caption' => LAN_MANAGE, 'perm' => '0', 'icon'=>'fas-cogs'),
|
||||
'main/meta' => array('caption' => LAN_MANAGE, 'perm' => '0', 'icon'=>'fas-list'),
|
||||
'main/prefs'=> array('caption' => "SEO", 'perm'=>'0', 'icon'=>'fas-cogs'),
|
||||
);
|
||||
|
||||
protected $adminMenuAliases = array(// 'main/edit' => 'main/list'
|
||||
@@ -58,6 +59,12 @@ class meta_admin_ui extends e_admin_ui
|
||||
protected $pluginTitle = METLAN_00;
|
||||
protected $pluginName = 'core';
|
||||
|
||||
protected $prefs = array(
|
||||
'seo_title_limit' => array('title'=>METLAN_8, 'type'=>'number', 'data'=>'int', 'help'=>'', 'writeParms'=>['size'=>'large']),
|
||||
'seo_description_limit' => array('title'=>METLAN_9, 'type'=>'number', 'data'=>'int', 'help'=>'', 'writeParms'=>['size'=>'large']),
|
||||
'meta_news_summary' => array('title'=>METLAN_3, 'type'=>'boolean', 'data'=>'int'),
|
||||
);
|
||||
|
||||
function init()
|
||||
{
|
||||
|
||||
@@ -91,7 +98,6 @@ class meta_admin_ui extends e_admin_ui
|
||||
}
|
||||
}
|
||||
|
||||
$cfg->set('meta_news_summary', varset($_POST['meta_news_summary']));
|
||||
$cfg->save(true, true, true);
|
||||
}
|
||||
|
||||
@@ -181,14 +187,7 @@ class meta_admin_ui extends e_admin_ui
|
||||
|
||||
$text .= "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>" . METLAN_3 . "</td>
|
||||
<td>
|
||||
<div class='auto-toggle-area autocheck'>" .
|
||||
$frm->checkbox('meta_news_summary', 1, varset($pref['meta_news_summary'])) . "
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class='buttons-bar center'>" .
|
||||
|
@@ -27,6 +27,32 @@ e107::css('inline', "
|
||||
|
||||
");
|
||||
|
||||
e107::js('footer-inline', '
|
||||
|
||||
$("#news-meta-title").focus(function() {
|
||||
|
||||
var title = $("#news-title").val() + " | " + "'.SITENAME.'";
|
||||
|
||||
if(!$(this).val())
|
||||
{
|
||||
$(this).val(title);
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).attr("placeholder",title);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#news-title").on("input change focus", function()
|
||||
{
|
||||
var title = $("#news-title").val() + " | " + "'.SITENAME.'";
|
||||
$("#news-meta-title").attr("placeholder",title);
|
||||
|
||||
});
|
||||
|
||||
');
|
||||
|
||||
class news_admin extends e_admin_dispatcher
|
||||
{
|
||||
|
||||
@@ -409,10 +435,8 @@ class news_sub_form_ui extends e_admin_form_ui
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
define('NEWS_TITLE_META_LIMIT', 50);
|
||||
define('NEWS_DIZ_META_LIMIT',155);
|
||||
// Main News Area.
|
||||
|
||||
class news_admin_ui extends e_admin_ui
|
||||
@@ -453,8 +477,9 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_body' => array('title' => "", 'type' => 'method', 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_extended' => array('title' => "", 'type' => null, 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'noedit'=>true, 'writeParms'=>'nolabel=1', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
|
||||
'news_meta_title' => array('title' => LAN_TITLE, 'type' => 'text', 'data'=>'safestr', 'filter'=>true, 'tab'=>1, 'inline'=>true, 'width' => 'auto', 'help'=>'', 'writeParms'=>['size'=>'xxlarge', 'placeholder'=>'', 'counter'=>0, 'maxlength'=> 255], 'nosort' => false),
|
||||
'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', 'maxlength'=>155, 'rows'=>2)),
|
||||
'news_meta_description' => array('title' => LAN_DESCRIPTION,'type' => 'textarea', 'data'=>'safestr','filter'=>true, 'tab'=>1, 'width' => 'auto', 'thclass' => '', 'help'=>'', 'class' => null, 'nosort' => false, 'writeParms'=>array('size'=>'xxlarge', 'counter'=>0, 'maxlength'=>255, 'rows'=>2)),
|
||||
'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')),
|
||||
@@ -773,8 +798,9 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_thumbnail',
|
||||
|
||||
'news_sef' ,
|
||||
'news_meta_keywords',
|
||||
'news_meta_title',
|
||||
'news_meta_description' ,
|
||||
'news_meta_keywords',
|
||||
'news_meta_robots' ,
|
||||
|
||||
|
||||
@@ -936,6 +962,44 @@ class news_admin_ui extends e_admin_ui
|
||||
|
||||
}
|
||||
|
||||
private function setSEOLimits()
|
||||
{
|
||||
$seoTitleLimit = (int) e107::pref('core', 'seo_title_limit', 50);
|
||||
$seoDescriptionLimit = (int) e107::pref('core', 'seo_description_limit', 155);
|
||||
|
||||
$this->fields['news_meta_title']['writeParms']['counter'] = $seoTitleLimit;
|
||||
$this->fields['news_meta_title']['help'] = e107::getParser()->lanVars(LAN_SEARCH_ENGINES_X_LIMIT, $seoTitleLimit);
|
||||
$this->fields['news_meta_description']['writeParms']['counter'] = $seoDescriptionLimit;
|
||||
$this->fields['news_meta_description']['help'] = e107::getParser()->lanVars(LAN_SEARCH_ENGINES_X_LIMIT, $seoDescriptionLimit);
|
||||
|
||||
}
|
||||
|
||||
function EditObserver()
|
||||
{
|
||||
parent::EditObserver();
|
||||
|
||||
$title = $this->getFieldVar('news_title'). ' | '.SITENAME;
|
||||
$placeholder = $this->getFieldVar('news_meta_title');
|
||||
|
||||
if(empty($placeholder))
|
||||
{
|
||||
$this->fields['news_meta_title']['writeParms']['placeholder'] = html_entity_decode($title);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fields['news_meta_title']['writeParms']['placeholder'] = html_entity_decode($placeholder);
|
||||
}
|
||||
|
||||
$this->setSEOLimits();
|
||||
|
||||
}
|
||||
|
||||
function CreateObserver()
|
||||
{
|
||||
parent::CreateObserver();
|
||||
$this->setSEOLimits();
|
||||
}
|
||||
|
||||
|
||||
function saveSettings()
|
||||
{
|
||||
|
@@ -305,6 +305,7 @@ CREATE TABLE news (
|
||||
news_sef varchar(200) NOT NULL default '',
|
||||
news_body longtext NOT NULL,
|
||||
news_extended longtext NOT NULL,
|
||||
news_meta_title varchar(255) NOT NULL default '',
|
||||
news_meta_keywords varchar(255) NOT NULL default '',
|
||||
news_meta_description text NOT NULL,
|
||||
news_meta_robots varchar(255) default '',
|
||||
|
@@ -11,15 +11,8 @@
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
if(!defined('USER_AREA'))
|
||||
{
|
||||
//overload is now possible, prevent warnings
|
||||
define('USER_AREA',TRUE);
|
||||
}
|
||||
if(!defined('ADMIN_AREA'))
|
||||
{
|
||||
define('ADMIN_AREA', false);
|
||||
}
|
||||
if(!defined('USER_AREA')) { define('USER_AREA',TRUE); }
|
||||
if(!defined('ADMIN_AREA')) { define('ADMIN_AREA', false); }
|
||||
|
||||
e107::getDebug()->logTime('(Header Top)');
|
||||
|
||||
|
@@ -6621,12 +6621,33 @@ var_dump($select_options);*/
|
||||
'data-sef-generate-confirm' => LAN_WILL_OVERWRITE_SEF . ' ' . LAN_JSCONFIRM,
|
||||
]) . '>' . LAN_GENERATE . '</a></span>';
|
||||
}
|
||||
elseif(!empty($parms['counter']) && empty($parms['post']))
|
||||
{
|
||||
$parms['class'] = 'tbox e-count';
|
||||
$parms['data-char-count'] = $parms['counter'];
|
||||
|
||||
if(!empty($parms['placeholder']) && (strlen($parms['placeholder']) > (int) $parms['counter']))
|
||||
{
|
||||
$parms['class'] .= " has-error";
|
||||
}
|
||||
|
||||
if(!isset($parms['pattern']))
|
||||
{
|
||||
$parms['pattern'] = '.{0,'.$parms['counter'].'}';
|
||||
}
|
||||
$charMsg = $tp->lanVars(defset('LAN_X_CHARS_REMAINING', '[x] chars remaining'), "<span>" . $parms['counter'] . "</span>");
|
||||
$parms['post'] = "<small" . $this->attributes([
|
||||
'id' => $this->name2id($key) . "-char-count",
|
||||
'class' => 'text-muted e-count-display',
|
||||
'style' => 'display:none',
|
||||
]) . ">" . $charMsg . "</small>";
|
||||
}
|
||||
|
||||
|
||||
if(!empty($parms['password'])) // password mechanism without the md5 storage.
|
||||
{
|
||||
$ret = vartrue($parms['pre']).$this->password($key, $value, $maxlength, $parms).vartrue($parms['post']);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$ret = vartrue($parms['pre']).$this->text($key, $value, $maxlength, $parms).vartrue($parms['post']); // vartrue($parms['__options']) is limited. See 'required'=>true
|
||||
@@ -6664,12 +6685,26 @@ var_dump($select_options);*/
|
||||
$parms['size'] = 'xxlarge';
|
||||
}
|
||||
|
||||
if(!empty($parms['maxlength']) && empty($parms['post']))
|
||||
if(!empty($parms['counter']) && empty($parms['post']))
|
||||
{
|
||||
$charMsg = $tp->lanVars(defset('LAN_X_CHARS_REMAINING', '[x] chars remaining'), "<span>" . $parms['maxlength'] . "</span>");
|
||||
$parms['class'] = 'tbox e-count';
|
||||
|
||||
if(!empty($parms['placeholder']) && (strlen($parms['placeholder']) > (int) $parms['counter']))
|
||||
{
|
||||
$parms['class'] .= " has-error";
|
||||
}
|
||||
|
||||
if(!isset($parms['pattern']))
|
||||
{
|
||||
$parms['pattern'] = '.{0,'.$parms['counter'].'}';
|
||||
}
|
||||
|
||||
|
||||
$parms['data-char-count'] = $parms['counter'];
|
||||
$charMsg = $tp->lanVars(defset('LAN_X_CHARS_REMAINING', '[x] chars remaining'), "<span>" . $parms['counter'] . "</span>");
|
||||
$parms['post'] = "<small" . $this->attributes([
|
||||
'id' => $this->name2id($key) . "-char-count",
|
||||
'class' => 'text-muted',
|
||||
'class' => 'text-muted e-count-display',
|
||||
'style' => 'display:none',
|
||||
]) . ">" . $charMsg . "</small>";
|
||||
}
|
||||
|
@@ -593,4 +593,6 @@ define("LAN_NO_SCRIPT_ACCESS_ASK", "If you believe this is an error, please ask
|
||||
define("LAN_UI_FILTER_TODAY", "Today");
|
||||
define("LAN_UI_FILTER_THIS_WEEK", "This Week");
|
||||
define("LAN_UI_FILTER_THIS_MONTH", "This Month");
|
||||
define("LAN_UI_FILTER_THIS_YEAR", "This Year");
|
||||
define("LAN_UI_FILTER_THIS_YEAR", "This Year");
|
||||
|
||||
define("LAN_SEARCH_ENGINES_X_LIMIT", "Read by search engines. Maximum [x] characters.");
|
||||
|
@@ -16,3 +16,6 @@ define("METLAN_4", "Custom tags (inside [x] tags)");
|
||||
define("METLAN_5", "Custom tags (after [x])");
|
||||
define("METLAN_6", "Custom tags (before [x])");
|
||||
define("METLAN_7", "Any meta data or custom HTML tags entered here (such as <script> tags or Google analytics code) will be included on every page of the website in their designated areas.");
|
||||
|
||||
define("METLAN_8", "SEO Title Character Limit");
|
||||
define("METLAN_9", "SEO Description Character Limit");
|
||||
|
@@ -653,13 +653,18 @@ class news_front
|
||||
e107::meta('robots', $news['news_meta_robots']);
|
||||
}
|
||||
|
||||
if($news['news_title'])
|
||||
if(!empty($news['news_title']))
|
||||
{
|
||||
e107::title($news['news_title']);
|
||||
e107::meta('og:type','article');
|
||||
e107::meta('twitter:card', 'summary');
|
||||
}
|
||||
|
||||
if(!empty($news['news_meta_title'])) // override title with meta title.
|
||||
{
|
||||
e107::title($news['news_meta_title']);
|
||||
}
|
||||
|
||||
if($news['news_meta_description'] && !defined('META_DESCRIPTION'))
|
||||
{
|
||||
e107::meta('description',$news['news_meta_description']);
|
||||
|
@@ -94,7 +94,7 @@ class social_admin
|
||||
|
||||
<div class="well social-plugin" style="width:450px">
|
||||
<div class="media">
|
||||
<div class="media-left">'.$tp->toImage($data['news_thumbnail'][0], array('w'=>100, 'h'=>100, 'crop'=>1, 'class'=>'media-object')).'</div>
|
||||
<div class="media-left"><a target="_blank" href="'.$shareData['url'].'" title="'.LAN_EFORM_010.'">'.$tp->toImage($data['news_thumbnail'][0], array('w'=>100, 'h'=>100, 'crop'=>1, 'class'=>'media-object')).'</a></div>
|
||||
<div class="media-body">
|
||||
<h4 class="media-header">'.$tp->post_toHTML($data['news_title']).'</h4>
|
||||
<p><small>'.$tp->post_toHTML($data['news_meta_description'])."</small></p>".$this->share($shareData).'
|
||||
|
@@ -1510,7 +1510,7 @@ thead tr{background-color:#363636;background-image:linear-gradient(to bottom,#44
|
||||
.btn-primary>[class^=icon-],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-menu>.active>a>[class^=icon-],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^=icon-],.dropdown-submenu:hover>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^=icon-],.icon-white,.nav-list>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^=icon-],.nav-pills>.active>a>[class*=" icon-"],.nav-pills>.active>a>[class^=icon-],.nav-tabs>li>a>[class^=icon-],.navbar-inverse .nav>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^=icon-],h1>[class^=icon-],h2>[class^=icon-],h3>[class^=icon-],h4>[class^=icon-],h5>[class^=icon-]{background-image:none}
|
||||
#admin-ui-nav-menu a.link-active{color:#fff}
|
||||
.tab-content{background-color:#373737}
|
||||
input:invalid:focus,select:invalid:focus,textarea:invalid:focus{border-color:red;box-shadow:0 1px 1px 0 rgba(255,0,0,.75) inset}
|
||||
.form-control.has-error,input:invalid,input:invalid:focus,select:invalid:focus,textarea:invalid:focus{border-color:red;box-shadow:0 1px 1px 0 rgba(255,0,0,.75) inset}
|
||||
td.forumheader{background-image:linear-gradient(#303030,#212121 60%,#171717);filter:none}
|
||||
.admin-left-panel-collapsed .admin-left-panel { width: 70px }
|
||||
.admin-left-panel-collapsed .admin-right-panel { width: calc(100% - 70px) }
|
||||
|
@@ -1527,7 +1527,7 @@ thead tr{background-color:#363636;background-image:linear-gradient(to bottom,#44
|
||||
.btn-primary>[class^=icon-],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-menu>.active>a>[class^=icon-],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^=icon-],.dropdown-submenu:hover>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^=icon-],.icon-white,.nav-list>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^=icon-],.nav-pills>.active>a>[class*=" icon-"],.nav-pills>.active>a>[class^=icon-],.nav-tabs>li>a>[class^=icon-],.navbar-inverse .nav>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^=icon-],h1>[class^=icon-],h2>[class^=icon-],h3>[class^=icon-],h4>[class^=icon-],h5>[class^=icon-]{background-image:none}
|
||||
#admin-ui-nav-menu a.link-active{color:#fff}
|
||||
.tab-content{background-color:#373737; border-left:1px solid rgba(255,255,255,0.1); border-right:1px solid rgba(255,255,255,0.1);border-bottom:1px solid rgba(255,255,255,0.1); border-bottom-left-radius: 4px;border-bottom-right-radius: 4px;border-top-right-radius: 4px;}
|
||||
input:invalid:focus,select:invalid:focus,textarea:invalid:focus{border-color:red;box-shadow:0 1px 1px 0 rgba(255,0,0,.75) inset}
|
||||
.form-control.has-error,input:invalid,input:invalid:focus,select:invalid:focus,textarea:invalid:focus{border-color:red;box-shadow:0 1px 1px 0 rgba(255,0,0,.75) inset}
|
||||
td.forumheader{background-image:linear-gradient(#303030,#212121 60%,#171717);filter:none}
|
||||
|
||||
/* Custom */
|
||||
|
@@ -1513,7 +1513,7 @@
|
||||
.btn-primary>[class^=icon-],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-menu>.active>a>[class^=icon-],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^=icon-],.dropdown-submenu:hover>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^=icon-],.icon-white,.nav-list>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^=icon-],.nav-pills>.active>a>[class*=" icon-"],.nav-pills>.active>a>[class^=icon-],.nav-tabs>li>a>[class^=icon-],.navbar-inverse .nav>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^=icon-],h1>[class^=icon-],h2>[class^=icon-],h3>[class^=icon-],h4>[class^=icon-],h5>[class^=icon-]{background-image:none}
|
||||
#admin-ui-nav-menu a.link-active{color:#fff}
|
||||
.tab-content{/*background-color:#373737*/}
|
||||
input:invalid:focus,select:invalid:focus,textarea:invalid:focus{border-color:red;box-shadow:0 1px 1px 0 rgba(255,0,0,.75) inset}
|
||||
.form-control.has-error,input:invalid,input:invalid:focus,select:invalid:focus,textarea:invalid:focus{border-color:red;box-shadow:0 1px 1px 0 rgba(255,0,0,.75) inset}
|
||||
td.forumheader{background-image:linear-gradient(#303030,#212121 60%,#171717);filter:none}
|
||||
|
||||
/* Custom */
|
||||
|
@@ -183,28 +183,36 @@ $(document).ready(function()
|
||||
$(this).html(orig + spin);
|
||||
});
|
||||
|
||||
$('textarea').on("input", function(){
|
||||
|
||||
if($(this).attr("maxlength") === undefined)
|
||||
|
||||
|
||||
$('.e-count').on("input focus", function(){
|
||||
|
||||
if($(this).attr("data-char-count") === undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var maxlength = $(this).attr("maxlength");
|
||||
var maxlength = $(this).attr("data-char-count");
|
||||
var currentLength = $(this).val().length;
|
||||
var countID = $(this).attr('id') + '-char-count';
|
||||
|
||||
if( currentLength >= maxlength )
|
||||
/* if( currentLength >= maxlength )
|
||||
{
|
||||
$('#'+ countID + ' span').text('0');
|
||||
}
|
||||
else
|
||||
else*/
|
||||
{
|
||||
$('#'+ countID).show();
|
||||
$('#'+ countID + ' span').text(maxlength - currentLength);
|
||||
}
|
||||
});
|
||||
|
||||
$('.e-count').focusout(function() {
|
||||
|
||||
var countID = $(this).attr('id') + '-char-count';
|
||||
$('#'+ countID).hide();
|
||||
})
|
||||
|
||||
|
||||
$('#e-modal-submit').click(function () {
|
||||
|
Reference in New Issue
Block a user