/** * * Load Plugin modules. * */ private function load_modules() { do_action('sptp_before_load_modules'); $this->option = apply_filters('sptp_module_option', new Option(), $this); $this->admin = apply_filters('sptp_module_admin', new Admin($this->option), $this); $this->rewrite = apply_filters('sptp_module_rewrite', new Rewrite($this->option), $this); $this->permalink = apply_filters('sptp_module_permalink', new Permalink($this->option), $this); $this->option->add_hooks(); $this->admin->add_hooks(); $this->rewrite->add_hooks(); $this->permalink->add_hooks(); do_action('sptp_after_load_modules'); do_action('sptp_modules_loaded'); }
* The page that displays a list of editions. * * PHP version 5 * * @license http://www.gnu.org/licenses/gpl.html GPL 3 * @version 0.9 * @link http://www.statedecoded.com/ * @since 0.1 */ /* * Setup the edition object. */ require_once INCLUDE_PATH . 'class.Edition.inc.php'; global $db; $edition_obj = new Edition(array('db' => $db)); $permalink_obj = new Permalink(array('db' => $db)); /* * Create a container for our content. */ $content = new Content(); $content->set('browser_title', 'Editions'); $content->set('page_title', '<h2>Editions</h2>'); /* * Get editions. */ $editions = $edition_obj->all(); $body = '<p> These are the available editions of the code. </p>'; $body .= '<ol class="edition-list">'; foreach ($editions as $edition) {
* Use the ID passed to look up the law. */ if (isset($args['relational_id'])) { $laws->law_id = filter_var($args['relational_id'], FILTER_SANITIZE_STRING); /* * Retrieve a copy of the law. */ $law = $laws->get_law(); } if (!isset($law) || $law === FALSE) { send_404(); } /* * Get our permalink data */ $permalink_obj = new Permalink(array('db' => $db)); $law->permalink = $permalink_obj->get_permalink($law->law_id, 'law', $law->edition_id); /* * Store a record that this section was viewed. */ $laws->record_view(); /* * If this is a request for a plain text version of this law, simply display that and exit. */ if (isset($_GET['plain_text'])) { /* * Instruct the browser that this is plain text. */ header("Content-Type: text/plain"); /* * Send the text, which is already formatted properly.
* The remainder of the count divided by the number of classes * yields the proper index for the row class. */ $class_index = $counter % count($row_classes); $row_class = $row_classes[$class_index]; $body .= ' <dt class="' . $row_class . '"><a href="' . $law->url . '">' . SECTION_SYMBOL . ' ' . $law->section_number . '</a></dt> <dd class="' . $row_class . '"><a href="' . $law->url . '">' . $law->catch_line . '</a></dd>'; $counter++; } $body .= '</dl>'; } /* * If this isn't the canonical page, show a canonical meta tag. */ $permalink_obj = new Permalink(array('db' => $db)); $permalink = $permalink_obj->get_permalink($struct->structure_id, 'structure', $struct->edition_id); if ($args['url'] !== $permalink->url) { $content->append('meta_tags', '<link rel="canonical" href="' . $permalink->url . '" />'); } /* * Put the shorthand $body variable into its proper place. */ $content->set('body', $body); unset($body); /* * Show edition info. */ $edition_data = $edition->find_by_id($struct->edition_id); $edition_list = $edition->all(); if ($edition_data && count($edition_list) > 1) {
/** * A stripped down version of the get_law() function. Used by the Autolinker. */ public function get_matching_sections($section, $edition_id, $fields = array()) { static $select_statement; if (!isset($select_statement)) { $sql = 'SELECT id, catch_line FROM laws WHERE section = :section AND edition_id = :edition_id ORDER BY order_by'; $select_statement = $this->db->prepare($sql); } $sql_args = array(':section' => $section, ':edition_id' => $edition_id); $select_result = $select_statement->execute($sql_args); if ($select_result === FALSE || $select_statement->rowCount() == 0) { return FALSE; } else { $permalink_obj = new Permalink(array('db' => $this->db)); $laws = $select_statement->fetchAll(PDO::FETCH_OBJ); foreach ($laws as $key => $law) { $permalink = $permalink_obj->get_preferred($law->id, 'law', $edition_id); $laws[$key]->url = $permalink->url; } return $laws; } }