function list_records($page, $with_buttons = FALSE) { // Counting the total number of records (subarrays) in the meta-array ---------------- // array index starts at 0; $count = count($this->records_array); $totalpages = ceil($count / $this->perpage); if ($page > $totalpages) { $page = $totalpages; } else { if ($page < 1) { $page = 1; } } //end equals the page number x the number of records per page $end = $this->perpage * $page; //start equals the last record of the previous page + 1 or prev page's $end val $start = $this->perpage * ($page - 1); //however, if we are on the first page, start = 1 if ($page == 1) { $start = 0; } //and if we are on the last page, end = total number of records if ($page == $totalpages) { $end = $count; } // Print out the records in whatever order they exist in the array //if asc, we have already reversed the array for ($i = $start; $i < $end; $i++) { extract($this->records_array[$i]); //allow us to display an edit or delete button depending on parameters we //were called with if (!FALSE == $with_buttons && in_array('delete', $with_buttons)) { $delete_button = '<p class="deleteRecordButton"><a href="delete_process.php?id=' . $id . '" title="Delete this record">Delete this record</a></p>'; } if (!FALSE == $with_buttons && in_array('edit', $with_buttons)) { $edit_button = '<p class="editRecordButton"><a href="edit.php?id=' . $id . '" title="Edit this record">Edit this record</a></p>'; } if ($with_buttons !== FALSE) { @($buttons_div = '<div class="modifyButtons">' . $edit_button . $delete_button . '</div>'); } else { $buttons_div = ''; } echo "\n\n <div class='gbookRecordBanner'></div>\n <div class='gbookRecord'>\n {$buttons_div}\n <p><span class='gbookRecordLabel'>{$this->DateLabelText}:</span> {$date} </p>\n <p><span class='gbookRecordLabel'>{$this->NameLabelText}:</span> {$name} </p>\n <p><span class='gbookRecordLabel'>{$this->EmailLabelText}:</span>\n <a href='mailto:" . display_email($email, $no_image = TRUE, $this->email_image_source) . "' />" . display_email($email, $no_image = FALSE, $this->email_image_source) . "</a>\n </p>\n <p class='gbookRecordMsg'><span class='gbookRecordLabel'>{$this->MessageLabelText}:</span> {$msg} </p>\n </div>\n\n "; } }
} elseif ($vars['a'] == 'del') { $err = del_email(); if ($err) { $url = get_back_location(); fatal_error("{$err}<br />Please return <a href='{$url}'>back</a> and fix these errors", 0); } } else { parse_email_config(); if (count($vars['attachments'])) { foreach ((array) $vars['attachments'] as $k => $v) { if ($v == '') { if (isset($vars['attachments'][$k])) { unset($vars['attachments'][$k]); } } } $vars['attachments'] = join("\n", (array) $vars['attachments']); } if ($vars['another_day'] != '' && $vars['reload']) { $vars['day'] = $vars['another_day']; } if ($vars['reload']) { $vars['save'] = 0; } if ($vars['save']) { if ($err = save_email()) { $t->assign('error', $err); } } display_email(); }