LightPressPlugin($frontend, $args, $dummy_run); } function run($hook, &$hook_data) { $context = $this->_frontend->context; $db =& $this->_frontend->db; $tpl =& $this->_frontend->tpl; $post =& $this->_frontend->current_post; $prev_url = $next_url = ''; if (!$post) return $this->hide(); $tpl_vars = array( 'PLUGIN_POSTNAVIGATION_PREV' => '', 'PLUGIN_POSTNAVIGATION_NEXT' => ''); $tpl->setFile('plugin_postnavigation', 'plugins/post_navigation.xml', true); $tables =& $this->_frontend->tables; // previous entry $q = "select p.id as post_id, p.post_name, p.post_title, p.post_category, UNIX_TIMESTAMP(p.post_date) as tstamp from {$tables['posts']} p where p.id <> {$post['post_id']} and {$this->_frontend->get_posts_clause} and UNIX_TIMESTAMP(p.post_date_gmt) <= '{$post['post_tstamp_gmt']}' and {$this->_frontend->only_published} order by p.post_date desc limit 1"; if ($db->query($q) > 0 ) { $row = $db->next(); $tpl_vars['plugin_postnavigation_prev_title'] = $row['post_title']; $tpl_vars['plugin_postnavigation_prev_permalink'] = $this->_frontend->getPermalink( $row['post_id'], $row['post_name'], $row['tstamp'], $row['post_category']); } else { $tpl->setBlock('plugin_postnavigation', 'plugin_postnavigation_prev'); } // next entry $q = "select p.id as post_id, p.post_name, p.post_title, p.post_category, UNIX_TIMESTAMP(p.post_date) as tstamp from {$tables['posts']} p where p.id <> {$post['post_id']} and {$this->_frontend->get_posts_clause} and UNIX_TIMESTAMP(p.post_date_gmt) >= '{$post['post_tstamp_gmt']}' and {$this->_frontend->only_published} order by p.post_date limit 1"; if ($db->query($q) > 0 ) { $row = $db->next(); $tpl_vars['plugin_postnavigation_next_title'] = $row['post_title']; $tpl_vars['plugin_postnavigation_next_permalink'] = $this->_frontend->getPermalink($row['post_id'], $row['post_name'], $row['tstamp'], $row['post_category']); } else { $tpl->setBlock('plugin_postnavigation', 'plugin_postnavigation_next'); } $tpl->setVar($tpl_vars); $tpl->parse('PLUGIN_POSTNAVIGATION', 'plugin_postnavigation'); } } ?>