[geeklog-hg] geeklog: Added an API to allow plugins and custom code to add me...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Wed Jan 22 06:24:41 EST 2014
changeset 9441:6819ec652073
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/6819ec652073
user: Kenji ITO <mystralkk at gmail.com>
date: Wed Jan 22 15:22:33 2014 +0900
description:
Added an API to allow plugins and custom code to add meta tags (feature request #0001519)
diffstat:
plugins/staticpages/functions.inc | 17 +-
public_html/article.php | 18 +-
public_html/index.php | 17 +-
public_html/lib-common.php | 426 +++++++++++++++++++++----------------
public_html/polls/index.php | 17 +-
system/classes/metatags.class.php | 356 +++++++++++++++++++++++++++++++
system/lib-plugins.php | 129 ++++++++--
7 files changed, 745 insertions(+), 235 deletions(-)
diffs (truncated from 2208 to 300 lines):
diff -r 2047c1c3e8ca -r 6819ec652073 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc Wed Jan 22 10:15:52 2014 +0900
+++ b/plugins/staticpages/functions.inc Wed Jan 22 15:22:33 2014 +0900
@@ -331,10 +331,21 @@
// Meta Tags
if ($_SP_CONF['meta_tags'] > 0) {
- $meta_description = $A['meta_description'];
- $meta_keywords = $A['meta_keywords'];
- $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
+ $headercode .= LB . PLG_getMetaTags(
+ 'staticpages', $page,
+ array (
+ array(
+ 'name' => 'description',
+ 'content' => $A['meta_description']
+ ),
+ array(
+ 'name' => 'keywords',
+ 'content' => $A['meta_keywords']
+ )
+ )
+ );
}
+
$page_title = $A['sp_page_title'];
if(empty($page_title)) {
$page_title = $A['sp_title'];
diff -r 2047c1c3e8ca -r 6819ec652073 public_html/article.php
--- a/public_html/article.php Wed Jan 22 10:15:52 2014 +0900
+++ b/public_html/article.php Wed Jan 22 15:22:33 2014 +0900
@@ -252,10 +252,20 @@
. XHTML . '>';
// Meta Tags
- If ($_CONF['meta_tags'] > 0) {
- $meta_description = $story->DisplayElements('meta_description');
- $meta_keywords = $story->DisplayElements('meta_keywords');
- $headercode .= COM_createMetaTags($meta_description, $meta_keywords);
+ if ($_CONF['meta_tags'] > 0) {
+ $headercode .= LB . PLG_getMetaTags(
+ 'article', $story->getSid(),
+ array(
+ array(
+ 'name' => 'description',
+ 'content' => $story->DisplayElements('meta_description')
+ ),
+ array(
+ 'name' => 'keywords',
+ 'content' => $story->DisplayElements('meta_keywords')
+ )
+ )
+ );
}
if ($story->DisplayElements('trackbackcode') == 0) {
diff -r 2047c1c3e8ca -r 6819ec652073 public_html/index.php
--- a/public_html/index.php Wed Jan 22 10:15:52 2014 +0900
+++ b/public_html/index.php Wed Jan 22 15:22:33 2014 +0900
@@ -398,10 +398,19 @@
if ($_CONF['meta_tags'] > 0) {
$result = DB_query ("SELECT meta_description, meta_keywords FROM {$_TABLES['topics']} WHERE tid = '{$topic}'");
$A = DB_fetchArray ($result);
-
- $meta_description = stripslashes($A['meta_description']);
- $meta_keywords = stripslashes($A['meta_keywords']);
- $header .= COM_createMetaTags($meta_description, $meta_keywords);
+ $header .= LB . PLG_getMetaTags(
+ 'homepage', '',
+ array(
+ array(
+ 'name' => 'description',
+ 'content' => stripslashes($A['meta_description'])
+ ),
+ array(
+ 'name' => 'keywords',
+ 'content' => stripslashes($A['meta_keywords'])
+ )
+ )
+ );
}
}
diff -r 2047c1c3e8ca -r 6819ec652073 public_html/lib-common.php
--- a/public_html/lib-common.php Wed Jan 22 10:15:52 2014 +0900
+++ b/public_html/lib-common.php Wed Jan 22 15:22:33 2014 +0900
@@ -551,7 +551,7 @@
// and one for the future...this check will set the latest one as featured
// solely
COM_featuredCheck();
-
+
// Geeklog now allows for articles to be published in the future. Because of
// this, we need to check to see if we need to rebuild the RDF file in the case
// that any such articles have now been published. Need to do this for comments
@@ -846,7 +846,7 @@
$label = $LANG01[35];
}
break;
-
+
case 'prefs':
if ($anon) {
$url = '';
@@ -1038,12 +1038,12 @@
foreach ($blocks as $block) {
$header->set_block('menunavigation', $block);
}
-
+
// Allow anything not in the blocks but in the rest of the template file to be displayed
$header->parse('menu_elements', 'menunavigation', true);
-
+
$header->set_var('doctype', $doctype . LB);
-
+
if (XHTML == '') {
$header->set_var('xmlns', '');
} else {
@@ -1325,7 +1325,7 @@
$header->parse( 'right_blocks', 'rightblocks', true );
}
}
-
+
// Set last topic session variable
if ($topic == TOPIC_ALL_OPTION) {
$topic = ''; // Do not save 'all' option. Nothing is the same thing
@@ -1335,7 +1335,7 @@
// Call any plugin that may want to include extra Meta tags
// or Javascript functions
$headercode .= PLG_getHeaderCode();
-
+
// Meta Tags
// 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage
if ($_CONF['meta_tags'] > 0) {
@@ -1343,7 +1343,7 @@
$meta_keywords = '';
$no_meta_description = 1;
$no_meta_keywords = 1;
-
+
//Find out if the meta tag description or keywords already exist in the headercode
if ($headercode != '') {
$pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im';
@@ -1369,12 +1369,12 @@
$no_meta_keywords = 0;
}
}
-
+
}
}
}
}
-
+
If (COM_onFrontpage() && $_CONF['meta_tags'] == 2) { // Display default meta tags only on home page
If ($no_meta_description) {
$meta_description = $_CONF['meta_description'];
@@ -1390,19 +1390,19 @@
$meta_keywords = $_CONF['meta_keywords'];
}
}
-
+
If ($no_meta_description OR $no_meta_keywords) {
$headercode .= COM_createMetaTags($meta_description, $meta_keywords);
}
}
-
+
$headercode = $_SCRIPTS->getHeader() . $headercode;
$header->set_var( 'plg_headercode', $headercode );
$header->set_var( 'layout_columns', 'js_off' );
$retval = $header->finish($header->parse('index_header', 'header'));
-
+
return $retval;
}
@@ -1517,7 +1517,7 @@
} else {
$displayRightBlocks = false;
}
-
+
if ($displayRightBlocks)
{
/* Check if an array has been passed that includes the name of a plugin
@@ -1536,7 +1536,7 @@
} else {
$rblocks = COM_showBlocks( 'right', $topic );
}
-
+
if( empty( $rblocks ))
{
$footer->set_var( 'geeklog_blocks', '');
@@ -1604,13 +1604,13 @@
// Call any plugin that may want to include extra JavaScript functions
$plugin_footercode = PLG_getFooterCode();
-
+
// Retrieve any JavaScript libraries, variables and functions
$footercode = $_SCRIPTS->getFooter();
-
+
// $_SCRIPTS code should be placed before plugin_footer_code but plugin_footer_code should still be allowed to set $_SCRIPTS
$footercode .= $plugin_footercode;
-
+
$footer->set_var('plg_footercode', $footercode);
// Actually parse the template and make variable substitutions
@@ -1735,11 +1735,11 @@
foreach ($blocks as $block) {
$header->set_block('menunavigation', $block);
}
-
+
$header->parse('menu_elements', 'menunavigation', true);
-
+
$header->set_var('doctype', $doctype . LB);
-
+
if (XHTML == '') {
$header->set_var('xmlns', '');
} else {
@@ -1937,7 +1937,7 @@
// Call to plugins to set template variables in the header
PLG_templateSetVars( 'header', $header );
-
+
if( $_CONF['left_blocks_in_footer'] == 1 )
{
$header->set_var( 'left_blocks', '' );
@@ -2024,7 +2024,7 @@
$header->parse( 'right_blocks', 'rightblocks', true );
}
}
-
+
// Set last topic session variable
if ($topic == TOPIC_ALL_OPTION) {
$topic = ''; // Do not save 'all' option. Nothing is the same thing
@@ -2034,7 +2034,7 @@
// Call any plugin that may want to include extra Meta tags
// or Javascript functions
$headercode .= PLG_getHeaderCode();
-
+
// Meta Tags
// 0 = Disabled, 1 = Enabled, 2 = Enabled but default just for homepage
if ($_CONF['meta_tags'] > 0) {
@@ -2042,7 +2042,7 @@
$meta_keywords = '';
$no_meta_description = 1;
$no_meta_keywords = 1;
-
+
//Find out if the meta tag description or keywords already exist in the headercode
if ($headercode != '') {
$pattern = '/<meta ([^>]*)name="([^"\'>]*)"([^>]*)/im';
@@ -2068,12 +2068,12 @@
$no_meta_keywords = 0;
}
}
-
+
}
}
}
}
-
+
If (COM_onFrontpage() && $_CONF['meta_tags'] == 2) { // Display default meta tags only on home page
If ($no_meta_description) {
$meta_description = $_CONF['meta_description'];
@@ -2089,12 +2089,12 @@
$meta_keywords = $_CONF['meta_keywords'];
}
}
-
+
If ($no_meta_description OR $no_meta_keywords) {
$headercode .= COM_createMetaTags($meta_description, $meta_keywords);
}
}
-
+
$header->set_var( 'breadcrumb_trail', $breadcrumbs );
More information about the geeklog-cvs
mailing list