[geeklog-cvs] geeklog: - Added meta description and meta keywords to polls plu...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sat Sep 19 10:20:23 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/27d076900eaf
changeset: 7325:27d076900eaf
user:      Tom <websitemaster at cogeco.net>
date:      Mon Sep 14 09:33:05 2009 -0400
description:
- Added meta description and meta keywords to polls plugin (displays for poll results and poll vote page).
- Updated staticpage plugin to use Geeklog's meta tags language variables where needed.

diffstat:

 plugins/polls/install_defaults.php              |   6 ++++++
 plugins/polls/language/english.php              |   3 ++-
 plugins/polls/language/english_utf-8.php        |   3 ++-
 plugins/polls/sql/mssql_install.php             |   4 +++-
 plugins/polls/sql/mssql_updates.php             |   3 ++-
 plugins/polls/sql/mysql_install.php             |   4 +++-
 plugins/polls/sql/mysql_updates.php             |   3 ++-
 plugins/polls/templates/admin/polleditor.thtml  |  10 +++++++++-
 plugins/staticpages/install_defaults.php        |   2 +-
 plugins/staticpages/language/english.php        |   2 --
 plugins/staticpages/language/english_utf-8.php  |   2 --
 public_html/admin/plugins/polls/index.php       |  27 +++++++++++++++++++++++----
 public_html/admin/plugins/staticpages/index.php |   4 ++--
 public_html/docs/english/polls.html             |   5 +++++
 public_html/polls/index.php                     |  16 +++++++++++++---
 15 files changed, 73 insertions(+), 21 deletions(-)

diffs (truncated from 329 to 300 lines):

diff -r 269358e160f8 -r 27d076900eaf plugins/polls/install_defaults.php
--- a/plugins/polls/install_defaults.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/install_defaults.php	Mon Sep 14 09:33:05 2009 -0400
@@ -83,6 +83,10 @@
  */
 $_PO_DEFAULT['aftersave'] = 'list';
 
+
+// Display Meta Tags for static pages (1 = show, 0 = don't) 
+$_PO_DEFAULT['meta_tags'] = 0;
+
 // Define default permissions for new polls created from the Admin panel.
 // Permissions are perm_owner, perm_group, perm_members, perm_anon (in that
 // order). Possible values:
@@ -134,6 +138,8 @@
                 0, 0, 0, 80, true, 'polls');
         $c->add('aftersave', $_PO_DEFAULT['aftersave'], 'select',
                 0, 0, 9, 90, true, 'polls');
+        $c->add('meta_tags', $_PO_DEFAULT['meta_tags'], 'select',
+                0, 0, 0, 100, true, 'polls');        
 
         $c->add('fs_permissions', NULL, 'fieldset', 0, 1, NULL, 0, true, 'polls');
         $c->add('default_permissions', $_PO_DEFAULT['default_permissions'],
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/language/english.php
--- a/plugins/polls/language/english.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/language/english.php	Mon Sep 14 09:33:05 2009 -0400
@@ -126,7 +126,8 @@
     'polladdresstime' => 'Voter IP Address valid for',
     'delete_polls' => 'Delete Polls with Owner?',
     'aftersave' => 'After Saving Poll',
-    'default_permissions' => 'Poll Default Permissions'
+    'default_permissions' => 'Poll Default Permissions',
+    'meta_tags' => 'Enable Meta Tags'
 );
 
 $LANG_configsubgroups['polls'] = array(
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/language/english_utf-8.php
--- a/plugins/polls/language/english_utf-8.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/language/english_utf-8.php	Mon Sep 14 09:33:05 2009 -0400
@@ -126,7 +126,8 @@
     'polladdresstime' => 'Voter IP Address valid for',
     'delete_polls' => 'Delete Polls with Owner?',
     'aftersave' => 'After Saving Poll',
-    'default_permissions' => 'Poll Default Permissions'
+    'default_permissions' => 'Poll Default Permissions',
+    'meta_tags' => 'Enable Meta Tags'
 );
 
 $LANG_configsubgroups['polls'] = array(
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/sql/mssql_install.php
--- a/plugins/polls/sql/mssql_install.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/sql/mssql_install.php	Mon Sep 14 09:33:05 2009 -0400
@@ -60,6 +60,8 @@
 CREATE TABLE [dbo].[{$_TABLES['polltopics']}] (
     [pid] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
     [topic] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
+    [meta_description] [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
+    [meta_keywords] [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,    
     [voters] [numeric](8, 0) NULL ,
     [questions] [int] NOT NULL ,
     [date] [datetime] NULL ,
@@ -120,7 +122,7 @@
 
 // default poll
 
-$DEFVALUES[] = "INSERT INTO {$_TABLES['polltopics']} (pid, topic, voters, questions, date, display, is_open, hideresults, commentcode, statuscode, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklogfeaturepoll', 'Tell us your opinion about Geeklog', 0, 2, NOW(), 1, 1, 1, 0, 0, {$_USER['uid']}, #group#, 3, 2, 2, 2);";
+$DEFVALUES[] = "INSERT INTO {$_TABLES['polltopics']} (pid, topic, meta_description, meta_keywords, voters, questions, date, display, is_open, hideresults, commentcode, statuscode, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklogfeaturepoll', 'Tell us your opinion about Geeklog', 'A poll about users opinions of Geeklog.', 'Poll, Geeklog, Opinion', 0, 2, NOW(), 1, 1, 1, 0, 0, {$_USER['uid']}, #group#, 3, 2, 2, 2);";
 
 $DEFVALUES[] = "INSERT INTO {$_TABLES['pollquestions']} (qid, pid, question) VALUES (0, 'geeklogfeaturepoll', 'What is the best new feature of Geeklog?');";
 $DEFVALUES[] = "INSERT INTO {$_TABLES['pollquestions']} (qid, pid, question) VALUES (1, 'geeklogfeaturepoll', 'What is the all-time best feature of Geeklog?');";
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/sql/mssql_updates.php
--- a/plugins/polls/sql/mssql_updates.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/sql/mssql_updates.php	Mon Sep 14 09:33:05 2009 -0400
@@ -38,7 +38,8 @@
         "ALTER TABLE {$_TABLES['pollanswers']} ALTER COLUMN [pid] VARCHARS(40)",
         "ALTER TABLE {$_TABLES['pollquestions']} ALTER COLUMN [pid] VARCHARS(40)",
         "ALTER TABLE {$_TABLES['polltopics']} ALTER COLUMN [pid] VARCHARS(40)",
-        "ALTER TABLE {$_TABLES['pollvoters']} ALTER COLUMN [pid] VARCHARS(40)"
+        "ALTER TABLE {$_TABLES['pollvoters']} ALTER COLUMN [pid] VARCHARS(40)",
+        "ALTER TABLE {$_TABLES['polltopics']} ADD meta_description [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL AFTER topic, ADD meta_keywords [meta_keywords] [varchar] (5000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL AFTER meta_description"
     )
 
 );
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/sql/mysql_install.php
--- a/plugins/polls/sql/mysql_install.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/sql/mysql_install.php	Mon Sep 14 09:33:05 2009 -0400
@@ -61,6 +61,8 @@
 CREATE TABLE {$_TABLES['polltopics']} (
   pid varchar(40) NOT NULL default '',
   topic varchar(255) default NULL,
+  meta_description TEXT NULL,
+  meta_keywords TEXT NULL,    
   voters mediumint(8) unsigned default NULL,
   questions int(11) NOT NULL default '0',
   date datetime default NULL,
@@ -99,7 +101,7 @@
 
 // default poll
 
-$DEFVALUES[] = "INSERT INTO {$_TABLES['polltopics']} (pid, topic, voters, questions, date, display, is_open, hideresults, commentcode, statuscode, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklogfeaturepoll', 'Tell us your opinion about Geeklog', 0, 2, NOW(), 1, 1, 1, 0, 0, {$_USER['uid']}, #group#, 3, 2, 2, 2);";
+$DEFVALUES[] = "INSERT INTO {$_TABLES['polltopics']} (pid, topic, meta_description, meta_keywords, voters, questions, date, display, is_open, hideresults, commentcode, statuscode, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon) VALUES ('geeklogfeaturepoll', 'Tell us your opinion about Geeklog', 'A poll about users opinions of Geeklog.', 'Poll, Geeklog, Opinion', 0, 2, NOW(), 1, 1, 1, 0, 0, {$_USER['uid']}, #group#, 3, 2, 2, 2);";
 
 $DEFVALUES[] = "INSERT INTO {$_TABLES['pollquestions']} (qid, pid, question) VALUES (0, 'geeklogfeaturepoll', 'What is the best new feature of Geeklog?');";
 $DEFVALUES[] = "INSERT INTO {$_TABLES['pollquestions']} (qid, pid, question) VALUES (1, 'geeklogfeaturepoll', 'What is the all-time best feature of Geeklog?');";
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/sql/mysql_updates.php
--- a/plugins/polls/sql/mysql_updates.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/sql/mysql_updates.php	Mon Sep 14 09:33:05 2009 -0400
@@ -38,7 +38,8 @@
         "ALTER TABLE {$_TABLES['pollanswers']} CHANGE pid pid varchar(40) NOT NULL default ''",
         "ALTER TABLE {$_TABLES['pollquestions']} CHANGE pid pid varchar(40) NOT NULL default ''",
         "ALTER TABLE {$_TABLES['polltopics']} CHANGE pid pid varchar(40) NOT NULL default ''",
-        "ALTER TABLE {$_TABLES['pollvoters']} CHANGE pid pid varchar(40) NOT NULL default ''"
+        "ALTER TABLE {$_TABLES['pollvoters']} CHANGE pid pid varchar(40) NOT NULL default ''",
+        "ALTER TABLE {$_TABLES['polltopics']} ADD meta_description TEXT NULL AFTER topic, ADD meta_keywords TEXT NULL AFTER meta_description"
     )
 
 );
diff -r 269358e160f8 -r 27d076900eaf plugins/polls/templates/admin/polleditor.thtml
--- a/plugins/polls/templates/admin/polleditor.thtml	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/polls/templates/admin/polleditor.thtml	Mon Sep 14 09:33:05 2009 -0400
@@ -7,10 +7,18 @@
                                             <td><input type="text" dir="ltr" name="pid" value="{poll_id}" size="40" maxlength="40"{xhtml}> {lang_donotusespaces}</td>
                                         </tr>
                                         <tr>
-                                            <td align="right">{lang_topic}:</td>
+                                            <td align="right" valign="top">{lang_topic}:</td>
                                             <td><input type="text" name="topic" value="{poll_topic}" size="50" maxlength="255"{xhtml}><br{xhtml}>{poll_topic_info}</td>
                                         </tr>
                                         <tr>
+                                            <td valign="top" align="right">{lang_metadescription}:</td>
+                                        <td><textarea name="meta_description" style="width:100%" rows="2">{meta_description}</textarea></td>
+                                        </tr>
+                                        <tr>
+                                            <td valign="top" align="right">{lang_metakeywords}:</td>
+                                            <td><textarea name="meta_keywords" style="width:100%" rows="2">{meta_keywords}</textarea></td>
+                                        </tr>                                          
+                                        <tr>
                                             <td align="right">{lang_mode}:</td>
                                             <td>
                                                 <select name="commentcode">
diff -r 269358e160f8 -r 27d076900eaf plugins/staticpages/install_defaults.php
--- a/plugins/staticpages/install_defaults.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/staticpages/install_defaults.php	Mon Sep 14 09:33:05 2009 -0400
@@ -110,7 +110,7 @@
 $_SP_DEFAULT['atom_max_items'] = 10;
 
 // Display Meta Tags for static pages (1 = show, 0 = don't) 
- $_SP_DEFAULT['meta_tags'] = 0;
+$_SP_DEFAULT['meta_tags'] = 0;
 
 /**
 * Initialize Static Pages plugin configuration
diff -r 269358e160f8 -r 27d076900eaf plugins/staticpages/language/english.php
--- a/plugins/staticpages/language/english.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/staticpages/language/english.php	Mon Sep 14 09:33:05 2009 -0400
@@ -107,8 +107,6 @@
     'edit' => 'Edit',
     'copy' => 'Copy',
     'limit_results' => 'Limit Results',
-    'meta_description' => 'Meta Description',
-    'meta_keywords' => 'Meta Keywords',    
     'search' => 'Search',
     'submit' => 'Submit'
 );
diff -r 269358e160f8 -r 27d076900eaf plugins/staticpages/language/english_utf-8.php
--- a/plugins/staticpages/language/english_utf-8.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/plugins/staticpages/language/english_utf-8.php	Mon Sep 14 09:33:05 2009 -0400
@@ -107,8 +107,6 @@
     'edit' => 'Edit',
     'copy' => 'Copy',
     'limit_results' => 'Limit Results',
-    'meta_description' => 'Meta Description',
-    'meta_keywords' => 'Meta Keywords',
     'search' => 'Search',
     'submit' => 'Submit'
 );
diff -r 269358e160f8 -r 27d076900eaf public_html/admin/plugins/polls/index.php
--- a/public_html/admin/plugins/polls/index.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/public_html/admin/plugins/polls/index.php	Mon Sep 14 09:33:05 2009 -0400
@@ -132,6 +132,8 @@
 * @param    array   $Q              Array of poll questions
 * @param    string  $mainpage       Checkbox: poll appears on homepage
 * @param    string  $topic          The text for the topic
+* @param    string  $meta_description
+* @param    string  $meta_keywords
 * @param    int     $statuscode     (unused)
 * @param    string  $open           Checkbox: poll open for voting
 * @param    string  $hideresults    Checkbox: hide results until closed
@@ -148,7 +150,7 @@
 * @return   string                  HTML redirect or error message
 *
 */
-function savepoll($pid, $old_pid, $Q, $mainpage, $topic, $statuscode, $open,
+function savepoll($pid, $old_pid, $Q, $mainpage, $topic, $meta_description, $meta_keywords, $statuscode, $open,
                   $hideresults, $commentcode, $A, $V, $R, $owner_id, $group_id,
                   $perm_owner, $perm_group, $perm_members, $perm_anon)
 
@@ -162,6 +164,8 @@
     list($perm_owner,$perm_group,$perm_members,$perm_anon) = SEC_getPermissionValues($perm_owner,$perm_group,$perm_members,$perm_anon);
 
     $topic = COM_stripslashes($topic);
+    $meta_description = COM_stripslashes($meta_description);
+    $meta_keywords = COM_stripslashes($meta_keywords);
     $pid = COM_sanitizeID($pid);
     $old_pid = COM_sanitizeID($old_pid);
     if (empty($pid)) {
@@ -246,6 +250,8 @@
     DB_delete($_TABLES['pollquestions'], 'pid', $del_pid);
 
     $topic = addslashes ($topic);
+    $meta_description = addslashes ($meta_description);
+    $meta_keywords = addslashes ($meta_keywords);
 
     $k = 0; // set up a counter to make sure we do assign a straight line of question id's
     $v = 0; // re-count votes sine they might have been changed
@@ -278,7 +284,7 @@
         }
     }
     // save topics after the questions so we can include question count into table
-    $sql = "'$pid','$topic',$v, $k, '" . date ('Y-m-d H:i:s');
+    $sql = "'$pid','$topic','$meta_description','$meta_keywords',$v, $k, '" . date ('Y-m-d H:i:s');
 
     if ($mainpage == 'on') {
         $sql .= "',1";
@@ -299,7 +305,7 @@
     $sql .= ",'$statuscode','$commentcode',$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon";
 
     // Save poll topic
-    DB_save($_TABLES['polltopics'],"pid, topic, voters, questions, date, display, "
+    DB_save($_TABLES['polltopics'],"pid, topic, meta_description, meta_keywords, voters, questions, date, display, "
            . "is_open, hideresults, statuscode, commentcode, owner_id, group_id, "
            . "perm_owner, perm_group, perm_members, perm_anon",$sql);
 
@@ -397,6 +403,8 @@
     } else {
         $T['pid'] = COM_makeSid ();
         $T['topic'] = '';
+        $T['meta_description'] = '';
+        $T['meta_keywords'] = '';
         $T['voters'] = 0;
         $T['display'] = 1;
         $T['is_open'] = 1;
@@ -419,6 +427,16 @@
     $poll_templates->set_var('lang_topic', $LANG25[9]);
     $poll_templates->set_var('poll_topic', htmlspecialchars ($T['topic']));
     $poll_templates->set_var('lang_mode', $LANG25[1]);
+    
+    $poll_templates->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
+    $poll_templates->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
+    if (!empty($T['meta_description'])) {
+        $poll_templates->set_var('meta_description', $T['meta_description']);
+    }
+    if (!empty($T['meta_keywords'])) {
+        $poll_templates->set_var('meta_keywords', $T['meta_keywords']);        
+    }
+    
 
     $poll_templates->set_var('status_options', COM_optionList ($_TABLES['statuscodes'], 'code,name', $T['statuscode']));
     $poll_templates->set_var('comment_options', COM_optionList($_TABLES['commentcodes'],'code,name',$T['commentcode']));
@@ -600,7 +618,8 @@
             $hideresults = COM_applyFilter ($_POST['hideresults']);
         }
         $display .= savepoll ($pid, $old_pid, $_POST['question'], $mainpage,
-                        $_POST['topic'], $statuscode, $open, $hideresults,
+                        $_POST['topic'], $_POST['meta_description'], $_POST['meta_keywords'], 
+                        $statuscode, $open, $hideresults,
                         COM_applyFilter ($_POST['commentcode'], true),
                         $_POST['answer'], $_POST['votes'], $_POST['remark'],
                         COM_applyFilter ($_POST['owner_id'], true),
diff -r 269358e160f8 -r 27d076900eaf public_html/admin/plugins/staticpages/index.php
--- a/public_html/admin/plugins/staticpages/index.php	Sat Sep 19 14:17:00 2009 +0200
+++ b/public_html/admin/plugins/staticpages/index.php	Mon Sep 14 09:33:05 2009 -0400
@@ -304,8 +304,8 @@
         $title = htmlspecialchars(stripslashes($A['sp_title']));
     }
     $sp_template->set_var('sp_title', $title);
-    $sp_template->set_var('lang_metadescription', $LANG_STATIC['meta_description']);
-    $sp_template->set_var('lang_metakeywords', $LANG_STATIC['meta_keywords']);
+    $sp_template->set_var('lang_metadescription', $LANG_ADMIN['meta_description']);
+    $sp_template->set_var('lang_metakeywords', $LANG_ADMIN['meta_keywords']);
     if (!empty($A['meta_description'])) {
         $sp_template->set_var('meta_description', $A['meta_description']);
     }
diff -r 269358e160f8 -r 27d076900eaf public_html/docs/english/polls.html
--- a/public_html/docs/english/polls.html	Sat Sep 19 14:17:00 2009 +0200
+++ b/public_html/docs/english/polls.html	Mon Sep 14 09:33:05 2009 -0400
@@ -90,6 +90,11 @@
     <li>'admin': go to the "Admin Home" page, i.e. Command & Control</li>
     </ul></td>
 </tr>
+<tr>
+  <td><a name="desc_meta_tags">meta_tags</a></td>
+  <td>false</td>
+  <td>Whether to include the meta tags of the poll when it is displayed.</td>
+</tr>
 </table>
 
 <h2>How do the polls work?</h2>
diff -r 269358e160f8 -r 27d076900eaf public_html/polls/index.php
--- a/public_html/polls/index.php	Sat Sep 19 14:17:00 2009 +0200



More information about the geeklog-cvs mailing list