'number of items to display'); var $default_context = LP_CONTEXT_AUTHOR; var $description = 'Modify the posts\' appearance in author\'s pages'; var $active = true; var $hooks = array('get_posts', 'parse_post'); var $posts_per_page = 30; function AuthorIndex(&$frontend, $args, $dummy_run=false) { $this->LightPressPlugin($frontend, $args, $dummy_run); if (!$dummy_run) { $this->posts_per_page = (int)$this->posts_per_page; if ($frontend->context['type'] != 'author' || basename($_SERVER['PHP_SELF']) == 'feed.php') { $this->active = false; return; } $tpl =& $frontend->tpl; $db =& $frontend->db; $frontend->options['posts_per_page'] = $this->posts_per_page; $q = "select * from {$frontend->tables['users']} where id = {$frontend->context['filter']}"; $db->query($q); $user = $db->next(); foreach (array('user_pass', 'user_email') as $k) { if (isset($user[$k])) unset($user[$k]); } $q = "select meta_key, meta_value from {$frontend->tables['usermeta']} where user_id = {$frontend->context['filter']}"; if ($db->query($q) > 0) { foreach ($db->all() as $row) { $k = "user_" . $row['meta_key']; if (!isset($user[$k])) $user[$k] = $row['meta_value']; } } else { return $this->hide(); } $contacts = array(); if (isset($user['user_url']) && !empty($user['user_url']) && $user['user_url'] != 'http://') $contacts[] = '' . $user['user_url'] . ''; if (isset($user['user_email']) && !empty($user['user_email'])) $contacts[] = '' . $user['user_email'] . ''; if (isset($user['user_icq']) && !empty($user['user_icq'])) $contacts[] = 'ICQ# ' . $user['user_icq']; if (isset($user['user_description']) && !empty($user['user_description'])) $user['user_description'] = html_entity_decode($user['user_description']); else $user['user_description'] = ''; $user['user_contacts'] = implode(' ~ ', $contacts); $user['display_name'] = $frontend->context['label']; $tpl->setVar($user); // build the feed URL $context_url = $frontend->context['url']; if ($frontend->raw_urls) $feed_url = str_replace('index.php', 'feed.php', $context_url); else if (substr($_SERVER['REQUEST_URI'], -1, 1) == '/') $feed_url = $_SERVER['REQUEST_URI'] . 'rss.xml'; else $feed_url = $_SERVER['REQUEST_URI'] . '/rss.xml'; $tpl->setVar('user_feed_url', $feed_url); } } function hide() { $tpl =& $this->_frontend->tpl; // play it on the safe side $tpl->setVar(array( 'user_nickname' => '', 'user_num_posts' => '')); if (isset($tpl->_files['index'])) { // ugh $tpl->setBlock('index', 'user_details'); $tpl->setVar('USER_DETAILS', ''); } } function run($hook, &$post) { if ($hook == 'get_posts') return; $content = ''; foreach (explode(' ', strip_tags($post['post_content'])) as $word) { if (strlen("$content $word") > 204) break; $content .= " $word"; } $post['post_content'] = $content; $post['user_num_posts'] = $this->_frontend->num_posts; } } ?>