summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-content/smarty-plugins/function.lastposts.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
commit4f3bce79bfb5851cef9e7bc655c91bb3093cc401 (patch)
tree10a0991fddeb0e075d7fa46e2b40e5dbc64d1e88 /wp-inst/wp-content/smarty-plugins/function.lastposts.php
downloadwordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.gz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.xz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.zip
Initial Import
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-content/smarty-plugins/function.lastposts.php')
-rw-r--r--wp-inst/wp-content/smarty-plugins/function.lastposts.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/wp-inst/wp-content/smarty-plugins/function.lastposts.php b/wp-inst/wp-content/smarty-plugins/function.lastposts.php
new file mode 100644
index 0000000..60da376
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/function.lastposts.php
@@ -0,0 +1,66 @@
+<?php
+
+/* $Id: function.lastposts.php,v 1.3 2005/01/09 11:54:18 donncha Exp $ */
+
+
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * Type: function
+ * Name: lastposts
+ * Purpose: Returns a list of the last posts to the blog
+ * -------------------------------------------------------------
+ */
+
+function getposts( $wpblog, $posts )
+{
+ global $wpdb;
+
+ $query = "SELECT ID, post_title
+ FROM ".$wpdb->posts."
+ WHERE unix_timestamp( post_date ) < unix_timestamp( NOW() )
+ AND post_status = 'publish'
+ ORDER BY `post_date` DESC LIMIT 0, ".intval( $posts );
+ $result = $wpdb->get_results( $query );
+ if( $result )
+ {
+ foreach( $result as $details )
+ {
+ $postdata[ $details->ID ] = stripslashes( strip_tags( $details->post_title ) );
+ }
+
+ return $postdata;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+function smarty_function_lastposts($params, &$smarty)
+{
+
+ global $wpblog;
+
+ $posts = 10;
+ extract($params);
+
+ if( $posts > 40 )
+ $posts = 40;
+
+ if( @include_once( "Cache/Function.php" ) )
+ {
+ $cache = new Cache_Function( 'file', array('cache_dir' => ABSPATH . "/wp-content/smarty-cache", 'filename_prefix' => 'lastposts_cache_' ), 600 );
+ $lastposts = $cache->call( "getposts", $wpblog, $posts );
+ }
+ else
+ {
+ $lastposts = getposts( $wpblog, $posts );
+ }
+
+ $smarty->assign( "lastposts", $lastposts );
+}
+
+/* vim: set expandtab: */
+
+?>