[geeklog-cvs] geeklog: Staticpages are now included in the What's New Block. C...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri Oct 30 08:57:50 EDT 2009


changeset 7402:f7706912e8be
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/f7706912e8be
user: Tom <websitemaster at cogeco.net>
date: Thu Oct 15 13:05:28 2009 -0400
description:
Staticpages are now included in the What's New Block. Configuration option included to disable staticpages from displaying in the block if a centerblock and/or execute PHP code.

Staticpages now have the option to not be included in the search results of Geeklog. This can be limited to just pages that are centerblocks and/or execute PHP code.

diffstat:

 plugins/staticpages/functions.inc              |  101 ++++++++++++++++++++++++-
 plugins/staticpages/install_defaults.php       |   51 ++++++++++--
 plugins/staticpages/language/english.php       |   16 +++-
 plugins/staticpages/language/english_utf-8.php |   16 +++-
 plugins/staticpages/sql/mssql_updates.php      |   14 +++
 plugins/staticpages/sql/mysql_updates.php      |   14 +++
 public_html/docs/english/staticpages.html      |   69 ++++++++++++++--
 7 files changed, 255 insertions(+), 26 deletions(-)

diffs (truncated from 456 to 300 lines):

diff -r 65103610c52f -r f7706912e8be plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Thu Oct 29 19:50:58 2009 +0100
+++ b/plugins/staticpages/functions.inc	Thu Oct 15 13:05:28 2009 -0400
@@ -572,11 +572,13 @@
 */
 function plugin_searchtypes_staticpages()
 {
-    global $LANG_STATIC;
+    global $LANG_STATIC, $_SP_CONF;
 
-    $tmp['staticpages'] = $LANG_STATIC['staticpages'];
-
-    return $tmp;
+    if ($_SP_CONF['includesearch'] == 1) {
+        $tmp['staticpages'] = $LANG_STATIC['staticpages'];
+        
+        return $tmp;
+    }
 }
 
 
@@ -1253,6 +1255,97 @@
 }
 
 /**
+* Return headlines for New Static Pages section in the What's New block, if enabled
+*
+* @return   mixed       array(headline, byline), or boolean false if disabled
+*
+*/
+function plugin_whatsnewsupported_staticpages()
+{
+    global $_SP_CONF, $LANG_STATIC, $LANG_WHATSNEW;
+
+    if ($_SP_CONF['hidenewstaticpages'] == 0) {
+        $retval = array($LANG_STATIC['pages'],
+                        COM_formatTimeString($LANG_WHATSNEW['new_last'],
+                                             $_SP_CONF['newstaticpagesinterval'])
+                       );
+    } else {
+        $retval = false;
+    }
+
+    return $retval;
+}
+
+/**
+* Return new Static Pages for the What's New block
+*
+* @return   string  HTML list of new staticpages
+*
+*/
+function plugin_getwhatsnew_staticpages()
+{
+    global $_CONF, $_TABLES, $_SP_CONF, $LANG_STATIC;
+
+    $retval = '';
+
+    $extra_sql = "";
+    if ($_SP_CONF['includecenterblocks'] == 0) {
+        $extra_sql =' AND sp_centerblock = 0';
+    }
+    if ($_SP_CONF['includephp'] == 0) {
+        $extra_sql .=' AND sp_php = 0';
+    }
+    
+    $sql = "SELECT sp_id, sp_title 
+        FROM {$_TABLES['staticpage']} 
+        WHERE NOT ISNULL(sp_content) AND (sp_date >= (date_sub(NOW(), INTERVAL {$_SP_CONF['newstaticpagesinterval']} SECOND))) 
+        {$extra_sql} 
+        " . COM_getPermSQL( 'AND' ) . " 
+        ORDER BY sp_date DESC LIMIT 15";
+
+    $result = DB_query( $sql );
+
+    $nrows = DB_numRows( $result );
+
+    if( $nrows > 0)
+    {
+        $newstaticpages = array();
+
+        for( $x = 0; $x < $nrows; $x++ )
+        {
+            $A = DB_fetchArray( $result );
+
+            $url = COM_buildUrl( $_CONF['site_url']
+                . '/staticpages/index.php?page=' . $A['sp_id'] );                
+
+            $title = COM_undoSpecialChars( stripslashes( $A['sp_title'] ));
+            $titletouse = COM_truncate( $title, $_SP_CONF['title_trim_length'],
+                                        '...' );
+            if( $title != $titletouse )
+            {
+                $attr = array('title' => htmlspecialchars($title));
+            }
+            else
+            {
+                $attr = array();
+            }
+            $astaticpage = str_replace( '$', '$', $titletouse );
+            $astaticpage = str_replace( ' ', ' ', $astaticpage );
+
+            $newstaticpages[] = COM_createLink($astaticpage, $url, $attr);
+        }
+
+        $retval .= COM_makeList( $newstaticpages, 'list-new-comments' );
+    }
+    else
+    {
+        $retval .= $LANG_STATIC['no_new_pages'] . '<br' . XHTML . '>' . LB;
+    }
+
+    return $retval;
+}
+
+/**
 * Return information for a static page
 *
 * @param    string  $sp_id      static page ID or '*'
diff -r 65103610c52f -r f7706912e8be plugins/staticpages/install_defaults.php
--- a/plugins/staticpages/install_defaults.php	Thu Oct 29 19:50:58 2009 +0100
+++ b/plugins/staticpages/install_defaults.php	Thu Oct 15 13:05:28 2009 -0400
@@ -97,6 +97,24 @@
 $_SP_DEFAULT['filter_html'] = 0;
 $_SP_DEFAULT['censor'] = 1;
 
+// What's New Block
+$_SP_DEFAULT['new_staticpages_interval'] = 1209600; // 2 weeks
+$_SP_DEFAULT['hide_new_staticpages'] = 0;
+$_SP_DEFAULT['title_trim_length'] = 20;
+$_SP_DEFAULT['include_centerblocks'] = 0;
+$_SP_DEFAULT['include_PHP'] = 0;
+
+// Search Results Filter
+$_SP_DEFAULT['include_search'] = 1;
+$_SP_DEFAULT['include_search_centerblocks'] = 0;
+$_SP_DEFAULT['include_search_PHP'] = 0;
+
+// The maximum number of items displayed when an Atom feed is requested
+$_SP_DEFAULT['atom_max_items'] = 10;
+
+// Display Meta Tags for static pages (1 = show, 0 = don't) 
+$_SP_DEFAULT['meta_tags'] = 0;
+
 // Define default permissions for new pages created from the Admin panel.
 // Permissions are perm_owner, perm_group, perm_members, perm_anon (in that
 // order). Possible values:
@@ -106,11 +124,6 @@
 // (a value of 1, ie. write-only, does not make sense and is not allowed)
 $_SP_DEFAULT['default_permissions'] = array(3, 2, 2, 2);
 
-// The maximum number of items displayed when an Atom feed is requested
-$_SP_DEFAULT['atom_max_items'] = 10;
-
-// Display Meta Tags for static pages (1 = show, 0 = don't) 
-$_SP_DEFAULT['meta_tags'] = 0;
 
 /**
 * Initialize Static Pages plugin configuration
@@ -161,11 +174,33 @@
                 0, 0, null, 110, true, 'staticpages');
         $c->add('meta_tags', $_SP_DEFAULT['meta_tags'], 'select',
                 0, 0, 0, 120, true, 'staticpages');
+
+        $c->add('fs_whatsnew', NULL, 'fieldset',
+                0, 1, NULL, 0, true, 'staticpages');
+        $c->add('newstaticpagesinterval',$_SP_DEFAULT['new_staticpages_interval'],'text',
+                0, 1, NULL, 10, TRUE, 'staticpages');
+        $c->add('hidenewstaticpages',$_SP_DEFAULT['hide_new_staticpages'],'select',
+                0, 1, 0, 20, TRUE, 'staticpages');
+        $c->add('title_trim_length',$_SP_DEFAULT['title_trim_length'],'text',
+                0, 1, NULL, 30, TRUE, 'staticpages');
+        $c->add('includecenterblocks',$_SP_DEFAULT['include_centerblocks'],'select',
+                0, 1, 0, 40, TRUE, 'staticpages');
+        $c->add('includephp',$_SP_DEFAULT['include_PHP'],'select',
+                0, 1, 0, 50, TRUE, 'staticpages');        
+        
+        $c->add('fs_search', NULL, 'fieldset',
+                0, 2, NULL, 0, true, 'staticpages');
+        $c->add('includesearch', $_SP_DEFAULT['include_search'], 'select',
+                0, 2, 0, 10, true, 'staticpages');
+        $c->add('includesearchcenterblocks',$_SP_DEFAULT['include_search_centerblocks'],'select',
+                0, 2, 0, 20, TRUE, 'staticpages');
+        $c->add('includesearchphp',$_SP_DEFAULT['include_search_PHP'],'select',
+                0, 2, 0, 30, TRUE, 'staticpages');   
         
         $c->add('fs_permissions', NULL, 'fieldset',
-                0, 1, NULL, 0, true, 'staticpages');
-        $c->add('default_permissions', $_SP_DEFAULT['default_permissions'],
-                '@select', 0, 1, 12, 120, true, 'staticpages');
+                0, 3, NULL, 0, true, 'staticpages');
+        $c->add('default_permissions', $_SP_DEFAULT['default_permissions'],'@select',
+                0, 3, 12, 120, true, 'staticpages');
 
     }
 
diff -r 65103610c52f -r f7706912e8be plugins/staticpages/language/english.php
--- a/plugins/staticpages/language/english.php	Thu Oct 29 19:50:58 2009 +0100
+++ b/plugins/staticpages/language/english.php	Thu Oct 15 13:05:28 2009 -0400
@@ -108,7 +108,9 @@
     'copy' => 'Copy',
     'limit_results' => 'Limit Results',
     'search' => 'Search',
-    'submit' => 'Submit'
+    'submit' => 'Submit',
+    'no_new_pages' => 'No new pages',
+    'pages' => 'Pages'
 );
 
 $PLG_staticpages_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
@@ -139,7 +141,15 @@
     'default_permissions' => 'Page Default Permissions',
     'aftersave' => 'After Saving Page',
     'atom_max_items' => 'Max. Pages in Webservices Feed',
-    'meta_tags' => 'Enable Meta Tags'
+    'meta_tags' => 'Enable Meta Tags',
+    'newstaticpagesinterval' => 'New Static Page Interval',
+    'hidenewstaticpages' => 'Hide New Static Pages',
+    'title_trim_length' => 'Title Trim Length',
+    'includecenterblocks' => 'Include Center Block Static Pages',
+    'includephp' => 'Include Static Pages with PHP',
+    'includesearch' => 'Enable Static Pages in Search',
+    'includesearchcenterblocks' => 'Include Center Block Static Pages',
+    'includesearchphp' => 'Include Static Pages with PHP'
 );
 
 $LANG_configsubgroups['staticpages'] = array(
@@ -148,6 +158,8 @@
 
 $LANG_fs['staticpages'] = array(
     'fs_main' => 'Static Pages Main Settings',
+    'fs_whatsnew' => 'What\'s New Block',
+    'fs_search' => 'Search Results',
     'fs_permissions' => 'Default Permissions'
 );
 
diff -r 65103610c52f -r f7706912e8be plugins/staticpages/language/english_utf-8.php
--- a/plugins/staticpages/language/english_utf-8.php	Thu Oct 29 19:50:58 2009 +0100
+++ b/plugins/staticpages/language/english_utf-8.php	Thu Oct 15 13:05:28 2009 -0400
@@ -108,7 +108,9 @@
     'copy' => 'Copy',
     'limit_results' => 'Limit Results',
     'search' => 'Search',
-    'submit' => 'Submit'
+    'submit' => 'Submit',
+    'no_new_pages' => 'No new pages',
+    'pages' => 'Pages'
 );
 
 $PLG_staticpages_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
@@ -139,7 +141,15 @@
     'default_permissions' => 'Page Default Permissions',
     'aftersave' => 'After Saving Page',
     'atom_max_items' => 'Max. Pages in Webservices Feed',
-    'meta_tags' => 'Enable Meta Tags'
+    'meta_tags' => 'Enable Meta Tags',
+    'newstaticpagesinterval' => 'New Static Page Interval',
+    'hidenewstaticpages' => 'Hide New Static Pages',
+    'title_trim_length' => 'Title Trim Length',
+    'includecenterblocks' => 'Include Center Block Static Pages',
+    'includephp' => 'Include Static Pages with PHP',
+    'includesearch' => 'Enable Static Pages in Search',
+    'includesearchcenterblocks' => 'Include Center Block Static Pages',
+    'includesearchphp' => 'Include Static Pages with PHP'    
 );
 
 $LANG_configsubgroups['staticpages'] = array(
@@ -148,6 +158,8 @@
 
 $LANG_fs['staticpages'] = array(
     'fs_main' => 'Static Pages Main Settings',
+    'fs_whatsnew' => 'What\'s New Block',
+    'fs_search' => 'Search Results',    
     'fs_permissions' => 'Default Permissions'
 );
 
diff -r 65103610c52f -r f7706912e8be plugins/staticpages/sql/mssql_updates.php
--- a/plugins/staticpages/sql/mssql_updates.php	Thu Oct 29 19:50:58 2009 +0100
+++ b/plugins/staticpages/sql/mssql_updates.php	Thu Oct 15 13:05:28 2009 -0400
@@ -73,6 +73,20 @@
         }
     }
 
+    // What's New Block
+    $c->add('fs_whatsnew', NULL, 'fieldset', 0, 1, NULL, 0, true, 'staticpages');
+    $c->add('newstaticpagesinterval',$_SP_DEFAULT['new_staticpages_interval'],'text', 0, 1, NULL, 10, TRUE, 'staticpages');
+    $c->add('hidenewstaticpages',$_SP_DEFAULT['hide_new_staticpages'],'select', 0, 1, 0, 20, TRUE, 'staticpages');
+    $c->add('title_trim_length',$_SP_DEFAULT['title_trim_length'],'text', 0, 1, NULL, 30, TRUE, 'staticpages');
+    $c->add('includecenterblocks',$_SP_DEFAULT['include_centerblocks'],'select', 0, 1, 0, 40, TRUE, 'staticpages');
+    $c->add('includephp',$_SP_DEFAULT['include_PHP'],'select', 0, 1, 0, 50, TRUE, 'staticpages');        
+    
+    // Search Results
+    $c->add('fs_search', NULL, 'fieldset', 0, 2, NULL, 0, true, 'staticpages');
+    $c->add('includesearch', $_SP_DEFAULT['include_search'], 'select', 0, 2, 0, 10, true, 'staticpages');
+    $c->add('includesearchcenterblocks',$_SP_DEFAULT['include_search_centerblocks'],'select', 0, 2, 0, 20, TRUE, 'staticpages');
+    $c->add('includesearchphp',$_SP_DEFAULT['include_search_PHP'],'select', 0, 2, 0, 30, TRUE, 'staticpages');   
+
     return true;
 }
 



More information about the geeklog-cvs mailing list