add('name', PLUGIN_EVENT_FILTER_ENTRIES_NAME); $propbag->add('description', PLUGIN_EVENT_FILTER_ENTRIES_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Garvin Hicking, Ian'); $propbag->add('version', '1.7.3'); $propbag->add('requirements', array( 'serendipity' => '1.6', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('event_hooks', array( 'external_plugin' => true, 'entries_footer' => true, 'frontend_configure' => true, 'frontend_fetchentries' => true )); $propbag->add('groups', array('FRONTEND_VIEWS')); $propbag->add('legal', array( 'services' => array( ), 'frontend' => array( 'Temporarily stores user-selected sort order and search restrictions in a PHP session variable on the server, which requires a PHP session cookie', ), 'backend' => array( ), 'cookies' => array( 'Temporarily stores user-selected sort order and search restrictions in a PHP session variable on the server, which requires a PHP session cookie', ), 'stores_user_input' => false, 'stores_ip' => false, 'uses_ip' => false, 'transmits_user_input' => false )); } function generate_content(&$title) { $title = $this->title; } function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks = &$bag->get('event_hooks'); $links = array(); if (isset($hooks[$event])) { $sort_order = array('timestamp' => DATE, 'isdraft' => PUBLISH . '/' . DRAFT, 'a.realname' => AUTHOR, 'category_name' => CATEGORY, 'last_modified' => LAST_UPDATED, 'title' => TITLE); $per_page_max = 50; $per_page = array('12', '16', '25', $per_page_max); switch($event) { case 'frontend_fetchentries': if ($this->fetchLimit > 0) { $serendipity['fetchLimit'] = $this->fetchLimit; } break; case 'frontend_configure': $_SERVER['REQUEST_URI'] = str_replace('%2Fplugin%2Ffilter%2F', '/plugin/filter/', $_SERVER['REQUEST_URI']); break; case 'entries_footer': $link = $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/filter/'; ?>


-
$v){ if ($v[0] == 'P') { /* Page */ $page = substr($v, 1); if (is_numeric($page)) { $serendipity['GET']['page'] = $page; unset($serendipity['uriArguments'][$k]); } } } switch($plugincode) { case 'filter': $perPage = (int)(!empty($_SESSION['sort']['perPage']) ? $_SESSION['sort']['perPage'] : $per_page[0]); if ($perPage > $per_page_max) { $perPage = $per_page_max; } $serendipity['fetchLimit'] = $perPage; $this->fetchLimit = $perPage; $page = (int)$serendipity['GET']['page']; if ($page == 0) $page = 1; $offSet = $perPage*($page-1); if (empty($_SESSION['sort']['ordermode']) || $_SESSION['sort']['ordermode'] != 'ASC') { $_SESSION['sort']['ordermode'] = 'DESC'; } if (!empty($_SESSION['sort']['order']) && !empty($sort_order[$_SESSION['sort']['order']])) { $orderby = serendipity_db_escape_string($_SESSION['sort']['order'] . ' ' . $_SESSION['sort']['ordermode']); } else { $orderby = 'timestamp ' . serendipity_db_escape_string($_SESSION['sort']['ordermode']); } $filter = array(); if (!empty($_SESSION['filter']['author'])) { $filter[] = "e.authorid = '" . serendipity_db_escape_string($_SESSION['filter']['author']) . "'"; } if (!empty($_SESSION['filter']['category'])) { $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($_SESSION['filter']['category']) . "'"; } if (!empty($_SESSION['filter']['body'])) { if ($serendipity['dbType'] == 'mysql' || $serendipity['dbType'] == 'mysqli') { $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($_SESSION['filter']['body']) . "')"; $full = true; } } $filter_sql = implode(' AND ', $filter); // Fetch the entries $entries = serendipity_fetchEntries( false, false, serendipity_db_limit( $offSet, $perPage ), true, false, $orderby, $filter_sql ); $serendipity['smarty_raw_mode'] = true; include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php'); serendipity_printEntries($entries); $raw_data = ob_get_contents(); ob_end_clean(); $serendipity['smarty']->assign('CONTENT', $raw_data); $serendipity['smarty']->assign('is_raw_mode', false); serendipity_gzCompression(); $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); break; } break; default: return false; } return true; } else { return false; } } } /* vim: set sts=4 ts=4 expandtab : */ ?>