3 * Name: Alternate Pagination
4 * Description: Change pagination from using explicit page numbers to simple "newer" and "older" page links. This will speed up page load times.
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 function altpager_install() {
14 register_hook('plugin_settings', 'addon/altpager/altpager.php', 'altpager_settings');
15 register_hook('plugin_settings_post', 'addon/altpager/altpager.php', 'altpager_settings_post');
17 logger("installed altpager");
21 function altpager_uninstall() {
23 unregister_hook('plugin_settings', 'addon/altpager/altpager.php', 'altpager_settings');
24 unregister_hook('plugin_settings_post', 'addon/altpager/altpager.php', 'altpager_settings_post');
27 logger("removed altpager");
34 * Callback from the settings post function.
35 * $post contains the $_POST array.
36 * We will make sure we've got a valid user account
37 * and if so set our configuration setting for this person.
41 function altpager_settings_post($a,$post) {
42 if(! local_user() || (! x($_POST,'altpager-submit')))
45 set_pconfig(local_user(),'system','alt_pager',intval($_POST['altpager']));
46 info( t('Altpager settings updated.') . EOL);
52 * Called from the Plugin Setting form.
53 * Add our own settings info to the page.
59 function altpager_settings(&$a,&$s) {
64 /* Add our stylesheet to the page so we can make our settings look nice */
66 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/altpager/altpager.css' . '" media="all" />' . "\r\n";
68 /* Get the current state of our config variable */
70 $altpager = get_pconfig(local_user(),'system','alt_pager');
71 if($altpager === false)
74 $checked = (($altpager) ? ' checked="checked" ' : '');
76 /* Add some HTML to the existing form */
78 $s .= '<div class="settings-block">';
79 $s .= '<h3>' . t('Alternate Pagination Setting') . '</h3>';
80 $s .= '<div id="altpager-wrapper">';
81 $s .= '<label id="altpager-label" for="altpager">' . t('Use links to "newer" and "older" pages in place of page numbers?') . '</label>';
82 $s .= '<input id="altpager-input" type="checkbox" name="altpager" value="1" ' . $checked . '/>';
83 $s .= '</div><div class="clear"></div>';
85 /* provide a submit button */
87 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="altpager-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';