コード例 #1
0
ファイル: section.php プロジェクト: udp12/theyworkforyou
                $plural = $row['contentcount'] == 1 ? 'speech' : 'speeches';
                $moreinfo[] = $row['contentcount'] . " {$plural}";
            }
            if ($row['totalcomments'] > 0) {
                $plural = $row['totalcomments'] == 1 ? 'annotation' : 'annotations';
                $moreinfo[] = $row['totalcomments'] . " {$plural}";
            }
            if (count($moreinfo) > 0) {
                print "<small>(" . implode(', ', $moreinfo) . ") </small>";
            }
        } else {
            // Nothing in this item, so no link.
            print $row['body'];
        }
        if (isset($row['excerpt'])) {
            print "<p class=\"subrows__excerpt\">" . trim_characters($row['excerpt'], 0, 200) . "</p>";
        }
    }
    print '</ul></div></div></div>';
}
if ($individual_item) {
    ?>
        <div class="debate-comments">
            <div class="full-page__row">
                <div class="full-page__unit">
                <?php 
    # XXX
    global $PAGE;
    $comments['object']->display('ep', $comments['args']);
    $PAGE->comment_form($comments['commentdata']);
    # XXX COMMENT SIDEBAR SHOULD GO HERE IF LOGGED IN
コード例 #2
0
 function prepare_search_result_for_display($body)
 {
     global $SEARCHENGINE;
     // We want to trim the body to an extract that is centered
     // around the position of the first search word.
     // we don't use strip_tags as it doesn't replace tags with spaces,
     // which means some words end up stuck together
     $extract = strip_tags_tospaces($body);
     // $bestpos is the position of the first search word
     $bestpos = $SEARCHENGINE->position_of_first_word($extract);
     // Where do we want to extract from the $body to start?
     $length_of_extract = 400;
     // characters.
     $startpos = $bestpos - $length_of_extract / 2;
     if ($startpos < 0) {
         $startpos = 0;
     }
     // Trim it to length and position, adding ellipses.
     $extract = trim_characters($extract, $startpos, $length_of_extract);
     // Highlight search words
     $extract = $SEARCHENGINE->highlight($extract);
     return $extract;
 }
コード例 #3
0
ファイル: hansardlist.php プロジェクト: rhaleblian/twfy
 function _get_data_by_search($args)
 {
     // Creates a fairly standard $data structure for the search function.
     // Will probably be rendered by the hansard_search.php template.
     // $args is an associative array with 's'=>'my search term' and
     // (optionally) 'p'=>1  (the page number of results to show) annd
     // (optionall) 'pop'=>1 (if "popular" search link, so don't log)
     global $PAGE, $hansardmajors;
     if (isset($args['s'])) {
         // $args['s'] should have been tidied up by the time we get here.
         // eg, by doing filter_user_input($s, 'strict');
         $searchstring = $args['s'];
     } else {
         $PAGE->error_message("No search string");
         return false;
     }
     // What we'll return.
     $data = array();
     $data['info']['s'] = $args['s'];
     // Allows us to specify how many results we want
     // Mainly for glossary term adding
     if (isset($args['num']) && $args['num']) {
         $results_per_page = $args['num'];
     } else {
         $results_per_page = 20;
     }
     if ($results_per_page > 1000) {
         $results_per_page = 1000;
     }
     $data['info']['results_per_page'] = $results_per_page;
     // What page are we on?
     if (isset($args['p']) && is_numeric($args['p'])) {
         $page = $args['p'];
     } else {
         $page = 1;
     }
     $data['info']['page'] = $page;
     if (isset($args['e'])) {
         $encode = 'url';
     } else {
         $encode = 'html';
     }
     // Fetch count of number of matches
     global $SEARCHENGINE;
     $data['searchdescription'] = $SEARCHENGINE->query_description_long();
     $count = $SEARCHENGINE->run_count();
     $data['info']['total_results'] = $count;
     // Log this query so we can improve them - if it wasn't a "popular
     // query" link
     if (!isset($args['pop']) or $args['pop'] != 1) {
         global $SEARCHLOG;
         $SEARCHLOG->add(array('query' => $searchstring, 'page' => $page, 'hits' => $count));
     }
     // No results.
     if ($count <= 0) {
         $data['rows'] = array();
         return $data;
     }
     // For Xapian's equivalent of an SQL LIMIT clause.
     $first_result = ($page - 1) * $results_per_page;
     $data['info']['first_result'] = $first_result + 1;
     // Take account of LIMIT's 0 base.
     // Get the gids from Xapian
     $sort_order = 'date';
     if (isset($args['o'])) {
         if ($args['o'] == 'd') {
             $sort_order = 'date';
         } elseif ($args['o'] == 'c') {
             $sort_order = 'created';
         } elseif ($args['o'] == 'r') {
             $sort_order = 'relevance';
         }
     }
     $SEARCHENGINE->run_search($first_result, $results_per_page, $sort_order);
     $gids = $SEARCHENGINE->get_gids();
     if ($sort_order == 'created') {
         $createds = $SEARCHENGINE->get_createds();
     }
     $relevances = $SEARCHENGINE->get_relevances();
     if (count($gids) <= 0) {
         // No results.
         $data['rows'] = array();
         return $data;
     }
     #if ($sort_order=='created') { print_r($gids); }
     // We'll put all the data in here before giving it to a template.
     $rows = array();
     // We'll cache the ids=>first_names/last_names of speakers here.
     $speakers = array();
     // We'll cache (sub)section_ids here:
     $hansard_to_gid = array();
     // Cycle through each result, munge the data, get more, and put it all in $data.
     for ($n = 0; $n < count($gids); $n++) {
         $gid = $gids[$n];
         $relevancy = $relevances[$n];
         if ($sort_order == 'created') {
             $created = substr($createds[$n], 0, strpos($createds[$n], ':'));
             if ($created < $args['threshold']) {
                 $data['info']['total_results'] = $n;
                 break;
             }
         }
         // Get the data for the gid from the database
         $q = $this->db->query("SELECT hansard.gid,\n                                    hansard.hdate,\n                                    hansard.section_id,\n                                    hansard.subsection_id,\n                                    hansard.htype,\n                                    hansard.major,\n                                    hansard.speaker_id,\n\t\t\t\t    hansard.hpos,\n                                    epobject.body\n                            FROM hansard, epobject\n                            WHERE hansard.gid = '{$gid}'\n                            AND hansard.epobject_id = epobject.epobject_id");
         if ($q->rows() > 1) {
             $PAGE->error_message("Got more than one row getting data for {$gid}");
         }
         if ($q->rows() == 0) {
             # This error message is totally spurious, so don't show it
             # $PAGE->error_message("Unexpected missing gid $gid while searching");
             continue;
         }
         $itemdata = array();
         $itemdata['gid'] = fix_gid_from_db($q->field(0, 'gid'));
         $itemdata['hdate'] = $q->field(0, 'hdate');
         $itemdata['htype'] = $q->field(0, 'htype');
         $itemdata['major'] = $q->field(0, 'major');
         $itemdata['section_id'] = $q->field(0, 'section_id');
         $itemdata['subsection_id'] = $q->field(0, 'subsection_id');
         $itemdata['relevance'] = $relevances[$n];
         $itemdata['speaker_id'] = $q->field(0, 'speaker_id');
         $itemdata['hpos'] = $q->field(0, 'hpos');
         //////////////////////////
         // 1. Trim and highlight the body text.
         $body = $q->field(0, 'body');
         // We want to trim the body to an extract that is centered
         // around the position of the first search word.
         // we don't use strip_tags as it doesn't replace tags with spaces,
         // which means some words end up stuck together
         $extract = strip_tags_tospaces($body);
         // $bestpos is the position of the first search word
         $bestpos = $SEARCHENGINE->position_of_first_word($extract);
         // Where do we want to extract from the $body to start?
         $length_of_extract = 400;
         // characters.
         $startpos = $bestpos - $length_of_extract / 2;
         if ($startpos < 0) {
             $startpos = 0;
         }
         // Trim it to length and position, adding ellipses.
         $extract = trim_characters($extract, $startpos, $length_of_extract);
         // Highlight search words
         $extract = $SEARCHENGINE->highlight($extract);
         $itemdata['body'] = $extract;
         //////////////////////////
         // 2. Create the URL to link to this bit of text.
         $id_data = array('major' => $itemdata['major'], 'htype' => $itemdata['htype'], 'gid' => $itemdata['gid'], 'section_id' => $itemdata['section_id'], 'subsection_id' => $itemdata['subsection_id']);
         // We append the query onto the end of the URL as variable 's'
         // so we can highlight them on the debate/wrans list page.
         $url_args = array('s' => $searchstring);
         $itemdata['listurl'] = $this->_get_listurl($id_data, $url_args, $encode);
         //////////////////////////
         // 3. Get the speaker for this item, if applicable.
         if ($itemdata['speaker_id'] != 0) {
             $itemdata['speaker'] = $this->_get_speaker($itemdata['speaker_id'], $itemdata['hdate']);
         }
         //////////////////////////
         // 4. Get data about the parent (sub)section. TODO: CHECK THIS for major==4
         if ($itemdata['major'] && $hansardmajors[$itemdata['major']]['type'] == 'debate') {
             // Debate
             if ($itemdata['htype'] != 10) {
                 $section = $this->_get_section($itemdata);
                 $itemdata['parent']['body'] = $section['body'];
                 #					$itemdata['parent']['listurl'] = $section['listurl'];
                 if ($itemdata['section_id'] != $itemdata['subsection_id']) {
                     $subsection = $this->_get_subsection($itemdata);
                     $itemdata['parent']['body'] .= ': ' . $subsection['body'];
                     #						$itemdata['parent']['listurl'] = $subsection['listurl'];
                 }
                 if ($itemdata['major'] == 5) {
                     $itemdata['parent']['body'] = 'NIA: ' . $itemdata['parent']['body'];
                 }
             } else {
                 // It's a section, so it will be its own title.
                 $itemdata['parent']['body'] = $itemdata['body'];
                 $itemdata['body'] = '';
             }
         } else {
             // Wrans or WMS
             $section = $this->_get_section($itemdata);
             $subsection = $this->_get_subsection($itemdata);
             $body = $hansardmajors[$itemdata['major']]['title'] . ' &#8212; ';
             if (isset($section['body'])) {
                 $body .= $section['body'];
             }
             if (isset($subsection['body'])) {
                 $body .= ': ' . $subsection['body'];
             }
             if (isset($subsection['listurl'])) {
                 $listurl = $subsection['listurl'];
             } else {
                 $listurl = '';
             }
             $itemdata['parent'] = array('body' => $body, 'listurl' => $listurl);
         }
         // Add this item's data onto the main array we'll be returning.
         $rows[] = $itemdata;
     }
     $data['rows'] = $rows;
     return $data;
 }
コード例 #4
0
ファイル: rdf.php プロジェクト: bruno/openaustralia-app
}
?>
</rdf:Seq>
</items>

</channel>

<?php 
$c = 0;
foreach ($all_news as $id => $news_row) {
    if ($c++ == 10) {
        break;
    }
    list($title, $content, $date) = $news_row;
    $url = "http://www.theyworkforyou.com" . news_individual_link($date, $title);
    $excerpt = trim_characters(news_format_body($content), 0, 250);
    $date = str_replace(" ", "T", $date) . "+00:00";
    ?>
<item rdf:about="<?php 
    echo $url;
    ?>
">
<title><?php 
    echo htmlspecialchars($title);
    ?>
</title>
<link><?php 
    echo $url;
    ?>
</link>
<description><?php 
コード例 #5
0
ファイル: hansard_recent_wms.php プロジェクト: leowmjw/twfy
    echo $count;
    ?>
"></a><strong><a href="<?php 
    echo $wran['list_url'];
    ?>
"><?php 
    echo $wran['parent']['body'] . ': ' . $wran['body'];
    ?>
</a></strong> <?php 
    echo format_date($wran['hdate'], LONGDATEFORMAT) . ' ' . $totalcomments;
    ?>
</dt>
				<dd><?php 
    if (sizeof($speaker)) {
        ?>
<a href="<?php 
        echo $speaker['url'];
        ?>
"><?php 
        echo member_full_name($speaker['house'], $speaker['title'], $speaker['first_name'], $speaker['last_name'], $speaker['constituency']);
        ?>
</a>: <?php 
    }
    echo trim_characters($wran['child']['body'], 0, 200);
    ?>
</dd>
<?php 
}
?>
				</dl>
コード例 #6
0
    function display($self_link) {
        $action = get_http_var('action');
        if ($action == "")
            $action = "listrules";
        if ($action <> "editrule" && $action <> "listrules") {
            print "<p>Unknown ratty admin display action '$action'</p>";
        }

        if ($action == "editrule") {
            if (!array_key_exists('sequence', $_POST)) {
                if (get_http_var('rule_id') == "") {
                    $ruledata = array();
                    $conditiondata = array();
                } else {
                    $ruledata = ratty_admin_get_rule($this->scope, get_http_var('rule_id'));
                    $ruledata['rule_id'] = get_http_var('rule_id');
                    $conditiondata = ratty_admin_get_conditions($this->scope, get_http_var('rule_id'));
                }
            } else {
                // Load data from form
                $ruledata = array();
                $ruledata['rule_id'] = intval(get_http_var('rule_id'));
                $ruledata['requests'] = intval(get_http_var('requests')); 
                $ruledata['interval'] = intval(get_http_var('interval'));
                $ruledata['sequence'] = intval(get_http_var('sequence'));
                $ruledata['note'] = get_http_var('note'); 
                $ruledata['message'] = get_http_var('message'); 
                $conditiondata = array();
                for ($ix = 1; get_http_var("condition$ix") != ""; $ix++) {
                    if (get_http_var("delete$ix") != "")
                        continue;
                    $condition = array();
                    /* Parse normal/inverted condition */
                    $c = get_http_var("condition$ix");
                    $condition['invert'] = (substr($c, 0, 1) == '+') ? 0 : 1;
                    $condition['condition'] = substr($c, 1, 1);
                    $condition['field'] = get_http_var("field$ix");
                    $condition['value'] = get_http_var("value$ix");
                    array_push($conditiondata, $condition);
                }
            }

            if (get_http_var('newfilter') != "") {
                array_push($conditiondata, array('condition' => 'E', 'invert' => 0));
            }
            if (get_http_var('newsingle') != "") {
                array_push($conditiondata, array("condition" => 'S', 'invert' => 0));
            }
            if (get_http_var('newdistinct') != "") {
                array_push($conditiondata, array("condition" => 'D', 'invert' => 0));
            }

            $form = new HTML_QuickForm('adminRattyRuleForm', 'post', $self_link);
            # Resplice conditions with numbers for form
            $cform = array();

            /* Copy condition data into form, fixing up normal/inverted rules
             * as we go. */
            for ($ix = 1; $ix <= count($conditiondata); ++$ix) {
                foreach ($conditiondata[$ix - 1] as $key => $value) {
                    if ($key == 'condition')
                        $cform["condition$ix"] = ($conditiondata[$ix - 1]['invert'] ? '-' : '+') . $value;
                    else if ($key != 'invert')
                        $cform[$key . $ix] = $value;
                }
            }
            $form->setDefaults(array_merge($ruledata, $cform));

            if (array_key_exists('rule_id', $ruledata))
                $form->addElement('hidden', 'rule_id', $ruledata['rule_id']);
            $form->addElement('hidden', 'page', $this->id);
            $form->addElement('hidden', 'action', $action);

            $form->addElement('header', '', $rule = "" ? 'New Rate-Limiting Rule' : 'Edit Rate-Limiting Rule');

            $titlegroup = array();
            $titlegroup[] = &HTML_QuickForm::createElement('text', 'note', null, array('size' => 40));
            $titlegroup[] = &HTML_QuickForm::createElement('static', null, null, "<b>Eval position:</b>");
            $titlegroup[] = &HTML_QuickForm::createElement('text', 'sequence', "Rule evaluation position:", array('size' => 5, 'maxlength' => 10));
            $form->addRule('sequence', 'Rule position must be numeric', 'numeric', null, 'server');
            $form->addGroup($titlegroup, "titlegroup", "Title of rule:", null, false);

            $limitgroup = array();
            $limitgroup[] = &HTML_QuickForm::createElement('text', 'requests', null, array('size' => 5, 'maxlength' => 10));
            $limitgroup[] = &HTML_QuickForm::createElement('static', null, null, "<b> hits every </b>");
            $limitgroup[] = &HTML_QuickForm::createElement('text', 'interval', null, array('size' => 5, 'maxlength' => 10));
            $limitgroup[] = &HTML_QuickForm::createElement('static', null, null, "<b> seconds</b>. Leave blank/zero to block completely.");
            $form->addGroup($limitgroup, "limitgroup", "Limit rate to:", null, false);

            $form->addElement('textarea', 'message', "Action when rule fires:<br>(for help see below)", array('rows' => 3, 'cols' => 60));
            $form->addRule('requests', 'Hit count must be numeric', 'numeric', null, 'server');
            $form->addRule('interval', 'Time period must be numeric', 'numeric', null, 'server');
            $form->addRule('note', 'Description is required', 'required', null, 'server');
            $form->addRule('requests', 'Requests is required', 'required', null, 'server');
            $form->addRule('interval', 'Interval is required', 'required', null, 'server');

            $form->addElement('header', '', 'Conditions for Rule');
    
            // Get list of fields from ratty
            $fieldarray = ratty_admin_available_fields($this->scope);
            sort($fieldarray);
            $fields = array();
            foreach ($fieldarray as $row) {
                list($field_name, $field_description, $field_examples) = $row;
                $fields[$field_name] = $field_name;
                if (count($field_examples) > 0) {
                    // Get field as an example
                    $example = $field_examples[0];
                    // Search for one that isn't empty
                    if (!$example and count($field_examples) > 1) {
                        $example = $field_examples[1];
                    }
                    $fields[$field_name] .= " (e.g. " .  trim_characters($example, 0, 20) . ")";
                }
            }

            // Grouped elements
            $ix = 0;
            foreach ($conditiondata as $condition) {
                $ix++;
                $condgroup = array();
                $condgroup[0] = &HTML_QuickForm::createElement('select', "field$ix", null, $fields);

                if ($condition['condition'] == 'S') {
                    $condgroup[1] = &HTML_QuickForm::createElement('hidden', "condition$ix", 'S');
                    $desc = 'Limit hits separately for each:';
                } else if ($condition['condition'] == 'D') {
                    $condgroup[1] = &HTML_QuickForm::createElement('hidden', "condition$ix", 'D');
                    $desc = 'Limit number of distinct values of:';
                } else {
                    $condgroup[1] = &HTML_QuickForm::createElement('select', "condition$ix", null, 
                            array(
                                '+E' => 'exactly equals',
                                '-E' => 'does not equal',
                                '+R' => 'matches regexp',
                                '-R' => 'does not match regexp',
                                '+T' => 'roughly matches text',
                                '-T' => 'does not roughly match text',
                                '+I' => 'matches IP mask',
                                '-I' => 'does not match IP mask',
                                '+>' => 'is greater than',
                                '+<' => 'is smaller than',
                                '+P' => 'is present',
                                '-P' => 'is not present',
                            )
                        );
                    $desc = 'Applies only when:';
                    $condgroup[2] = &HTML_QuickForm::createElement('text', "value$ix", null, array('size' => 15));
                }
                array_push($condgroup, HTML_QuickForm::createElement('submit', "delete$ix", 'Del'));
                $form->addGroup($condgroup, "c$ix", $desc, null, false);
                $form->addRule("c$ix", 'Please use a valid regular expression', 'callback', 'check_condition_regexp');

            }

            $buttongroup[0] = &HTML_QuickForm::createElement('submit', 'newfilter', 'Apply only when...');
            $buttongroup[1] = &HTML_QuickForm::createElement('submit', 'newsingle', 'Limit hits separately for each...');
            $buttongroup[2] = &HTML_QuickForm::createElement('submit', 'newdistinct', 'Limit number of distinct values of...');
            $form->addGroup($buttongroup, "buttongroup", "Add new rule condition:",' <br> ', false);

            $form->addElement('header', '', 'Submit Changes');
            $finalgroup = array();
            $finalgroup[] = &HTML_QuickForm::createElement('submit', 'done', 'Done');
            $finalgroup[] = &HTML_QuickForm::createElement('submit', 'cancel', 'Cancel');
            $finalgroup[] = &HTML_QuickForm::createElement('submit', 'deleterule', 'Delete Rule');
            $form->addGroup($finalgroup, "finalgroup", "",' ', false);

            if (get_http_var('done') != "") {
                if ($form->validate()) {
                    $new_rule_id = ratty_admin_update_rule($this->scope, $ruledata, $conditiondata);
                    $action = "listrules";
                }
            } else if (get_http_var('cancel') != "") {
                $action = "listrules";
            } else if (get_http_var('deleterule') != "") {
                if ($ruledata['rule_id'] != "") {
                    ratty_admin_delete_rule($this->scope, $ruledata['rule_id']);
                }
                $action = "listrules";
            }
            
            if ($action == "editrule") {
                admin_render_form($form);

                print "<h2>Help &mdash; What goes in the action box?</h2>";
                print $this->scope_messageblurb; 
                print "<h2>Help &mdash; What do all the fields mean?</h2>";
                print "<p>";
                foreach ($fieldarray as $row) {
                    list($field_name, $field_description, $field_examples) = $row;
                    print "<b>$field_name:</b> $field_description. ";
                    print "e.g. " . implode(", ", array_map(
                    create_function('$a', 'return "\'".trim_characters($a, 0, 50)."\'";'), $field_examples));
                    print "<br>";
                }
                print "</p>";
            }
        }
        if ($action == "listrules") {
            $rules = ratty_admin_get_rules($this->scope);
            print <<<EOF
<h2>$this->scope_title Rules</h2> 
<p>$this->scope_description</p>
<table border="1" width="100%">
    <tr>
        <th>Order</th>
        <th>Description</th>
        <th>Hit limit</th>
        <th>Action</th>
        <th>Matches in<br>time period[1]</th>
EOF;
            if ($this->scope == "fyr-abuse") {
                print "<th>Messages</th>";
            }
            print <<<EOF
    </tr>
EOF;
            $c = 1;
            foreach ($rules as $rule) {
                if ($rule['note'] == "") 
                    $rule['note'] = "&lt;unnamed&gt;";
                print '<tr'.($c==1?' class="v"':'').'>';
                print "<td>" . $rule['sequence'] . "</td>";
                print "<td><a href=\"$self_link&amp;action=editrule&amp;rule_id=" .     /* XXX use url_new... */
                    $rule['id'] . "\">" . $rule['note'] . "</a></td>";
                if ($rule['requests'] == 0 && $rule['interval'] == 0) {
                    print "<td>blocked</td>";
                } else {
                    print "<td>" . $rule['requests'] . " hits / " . $rule['interval'] . " " . make_plural($rule['interval'], 'sec'). "</td>";
                }
                print "<td>" . trim_characters($rule['message'], 0, 40) . "</td>";
                print "<td>" . $rule['hits'] . "</td>";
                if ($this->scope == "fyr-abuse") {
                    print "<td><a href=\"?page=fyrqueue&amp;view=logsearch&amp;query=" .     /* XXX use url_new... */
                    urlencode(" rule #" . $rule['id'] . " ") . "\">View</a></td>";
                }
                print "</tr>";

                $c = 1 - $c;
            }
?>
</table>
<?
            print "<p><a href=\"$self_link&amp;action=editrule\">New rule</a>";
?>
<h2>Help &mdash; how do these rules work?</h2>
<p>
Each rule has a hit rate limit, which limits the number of times a
request or operation is permitted to, at most, the maximum number of
hits in any given specific time period.  (You can set the hit limit to 0
to completely block access.)
</p>
<p>
Conditions within the rule let you specify when it applies.  For example, you
can apply the rule only for certain URLs, IP addresses or postcodes. You can
also make the rule count limits separately for each distinct value of
something, for example, IP addresses, or alternatively limit the number of
distinct representatives which can be viewed per unit time.
</p>
<p>
Rules are applied in order. Each request is tested against each rule in turn
until one matches, in which case the request is denied; or until there are no
more rules, in which case the request is permitted.
</p>
<p>[1] <b>Matches</b> has slightly different meanings for different rules types.
For straightforward filter rules, it means the number of hits in the last 
time period (roughly - it actually means the number of hits in the time period
up until the last hit).  "Time period" here is the number of seconds in the
"Hit limit" column.  For more complicated "Limit hits separately..." and "Limit
number of distinct..." rules, matches is a count of how many times just the 
simple filter conditions were met, not how many times the rule actually triggered.
Note that if the time period is zero, you don't get very useful results.
</p>
<?
        }

    }
コード例 #7
0
ファイル: hansard_gid.php プロジェクト: henare/theyworkforyou
function generate_commentteaser (&$row, $major, $action_links) {
	// Returns HTML for the one fragment of comment and link for the sidebar.
	// $totalcomments is the number of comments this item has on it.
	// $comment is an array like:
	/* $comment = array (
		'comment_id' => 23,
		'user_id'	=> 34,
		'body'		=> 'Blah blah...',
		'posted'	=> '2004-02-24 23:45:30',
		'username'	=> 'phil'
		)
	*/
	// $url is the URL of the item's page, which contains comments.
	
	global $this_page, $THEUSER, $hansardmajors;
	
	$html = '';
	
        //Action links
    if (isset($action_links)) {
        $html .= '<ul>';
            foreach ($action_links as $action_link) {
				if (!is_array($action_link)) {
					$html .= $action_link;
					continue;
				}
                $html .= '<li>';
                $html .= '<a href="' . $action_link['link'] . '" class="' . $action_link['class'] . '"';
				if (isset($action_link['title'])) {
					$html .= ' title="' . $action_link['title'] . '"';
				}
                if (isset($action_link['onclick'])) {
                    $html .= ' onclick="' . $action_link['onclick']  . '"';
                }
                $html .= '>';
                $html .= $action_link["text"];                                    
                $html .= '</a>';
				if (isset($action_link['after']) && $action_link['after']) {
				    $html .= ' (' . $action_link['after'] . ')';
				}
                $html .= "</li>\n";
            }
        $html .= '</ul>';        
    }

	if ($hansardmajors[$major]['type'] == 'debate' && $hansardmajors[$major]['page_all']==$this_page) {

//		$html .= ' <a href="' .  $row['commentsurl'] . '" title="Copy this URL to link directly to this piece of text" class="permalink">Link to this</a>';
		
		// Build the 'Add an annotation' link.
		if (!$THEUSER->isloggedin()) {
			$URL = new URL('userprompt');
			$URL->insert(array('ret'=>$row['commentsurl']));
			$commentsurl = $URL->generate();
		} else {
			$commentsurl = $row['commentsurl'];
		}
		
		$html .= '<div class="add"><a class="annotate" href="' . $commentsurl . '#addcomment" title="Annotate this speech">Add an annotation</a> <small>(e.g. more info, blog post or wikipedia article)</small></div>';
		
		//Add existing annotations
		if ($row['totalcomments'] > 0) {
			$comment = $row['comment'];
			
			// If the comment is longer than the speech body, we want to trim it
			// to be the same length so they fit next to each other.
			// But the comment typeface is smaller, so we scale things slightly too...
			$targetsize = round(strlen($row['body']) * 0.6);
			
			if ($targetsize > strlen($comment['body'])) {
				// This comment will fit in its entirety.
				$commentbody = $comment['body'];

				if ($row['totalcomments'] > 1) {
					$morecount = $row['totalcomments'] - 1;
					$plural = $morecount == 1 ? 'annotation' : 'annotations';
					$linktext = "Read $morecount more $plural";
				}
				
			} else {
				// This comment needs trimming.
				$commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
				if ($row['totalcomments'] > 1) {
					$morecount = $row['totalcomments'] - 1;
					$plural = $morecount == 1 ? 'annotation' : 'annotations';
					$linktext = "Continue reading (and $morecount more $plural)";
				} else {
					$linktext = 'Continue reading';
				}
			}

			$html .= '<blockquote><p>' . prepare_comment_for_display($commentbody) . '</p><cite>Submitted by ' . htmlentities($comment['username']) . '</cite></small></blockquote>' ;
			
			if (isset($linktext)) {
				$html .= ' <a class="morecomments" href="' . $row['commentsurl'] . '#c' . $comment['comment_id'] . '" title="See any annotations posted about this">' . $linktext . '</a>';
			}
			
		}


	}
	$html = "\t\t\t\t" . '<div class="comment-teaser">' . $html . "</div>\n";
	
	return $html;
}
コード例 #8
0
    if (isset($data['full_name'])) {
        $title .= ' on things by ' . $data['full_name'];
    }
    $PAGE->block_start(array('id' => 'recentcomments', 'title' => $title));
    if ($this_page != 'home') {
        $PAGE->page_links($data);
    }
    $USERURL = new URL('userview');
    ?>
                        <ul>
<?php 
    foreach ($data['comments'] as $n => $comment) {
        ?>

                        <li><?php 
        $commenttext = trim_characters($comment['body'], 0, 200, 40);
        list($date, $time) = explode(' ', $comment['posted']);
        $date = format_date($date, SHORTDATEFORMAT);
        $time = format_time($time, TIMEFORMAT);
        $count = $n + 1;
        $USERURL->insert(array('u' => $comment['user_id']));
        ?>
<a name="c<?php 
        echo $count;
        ?>
"></a><strong><?php 
        echo _htmlentities($comment['firstname'] . ' ' . $comment['lastname']);
        ?>
:</strong> <?php 
        echo $commenttext;
        ?>
コード例 #9
0
 /**
  * Output Page
  *
  * Assembles a completed page from template and sends it to output.
  *
  * @param string $template The name of the template file to load.
  * @param array  $data     An associative array of data to be made available to the template.
  */
 public static function output($template, $data = array())
 {
     // Include includes.
     // TODO: Wrap these in a class somewhere autoloadable.
     include_once INCLUDESPATH . 'postcode.inc';
     ////////////////////////////////////////////////////////////
     // Find the user's country. Used by header, so a safe bit to do regardless.
     if (preg_match('#^[A-Z]{2}$#i', get_http_var('country'))) {
         $data['country'] = strtoupper(get_http_var('country'));
     } else {
         $data['country'] = Gaze::get_country_by_ip($_SERVER["REMOTE_ADDR"]);
     }
     ////////////////////////////////////////////////////////////
     // Get the page data
     global $DATA, $this_page, $THEUSER;
     ////////////////////////////////////////////////////////////
     // Assemble the page title
     $data['page_title'] = '';
     $sitetitle = $DATA->page_metadata($this_page, "sitetitle");
     $keywords_title = '';
     if ($this_page == 'overview') {
         $data['page_title'] = $sitetitle . ': ' . $DATA->page_metadata($this_page, "title");
     } else {
         if ($page_title = $DATA->page_metadata($this_page, "title")) {
             $data['page_title'] = $page_title;
         }
         // We'll put this in the meta keywords tag.
         $keywords_title = $data['page_title'];
         $parent_page = $DATA->page_metadata($this_page, 'parent');
         if ($parent_title = $DATA->page_metadata($parent_page, 'title')) {
             if ($data['page_title']) {
                 $data['page_title'] .= ': ';
             }
             $data['page_title'] .= $parent_title;
         }
         if ($data['page_title'] == '') {
             $data['page_title'] = $sitetitle;
         } else {
             $data['page_title'] .= ' - ' . $sitetitle;
         }
     }
     ////////////////////////////////////////////////////////////
     // Meta keywords
     if (!($data['meta_keywords'] = $DATA->page_metadata($this_page, "meta_keywords"))) {
         $data['meta_keywords'] = $keywords_title;
         if ($data['meta_keywords']) {
             $data['meta_keywords'] .= ', ';
         }
         $data['meta_keywords'] .= 'Hansard, Official Report, Parliament, government, House of Commons, House of Lords, MP, Peer, Member of Parliament, MPs, Peers, Lords, Commons, Scottish Parliament, Northern Ireland Assembly, MSP, MLA, MSPs, MLAs';
     }
     $data['meta_description'] = '';
     if ($DATA->page_metadata($this_page, "meta_description")) {
         $data['meta_description'] = $DATA->page_metadata($this_page, "meta_description");
     }
     ////////////////////////////////////////////////////////////
     // Header <link>s
     $data['header_links'] = array();
     if ($this_page != 'overview') {
         $URL = new \URL('overview');
         $data['header_links'][] = array('rel' => 'start', 'title' => 'Home', 'href' => $URL->generate());
     }
     ////////////////////////////////////////////////////////////
     // Create the next/prev/up links for navigation.
     // Their data is put in the metadata in hansardlist.php
     $nextprev = $DATA->page_metadata($this_page, "nextprev");
     if ($nextprev) {
         // Four different kinds of back/forth links we might build.
         $links = array("first", "prev", "up", "next", "last");
         foreach ($links as $type) {
             if (isset($nextprev[$type]) && isset($nextprev[$type]['url'])) {
                 if (isset($nextprev[$type]['body'])) {
                     $linktitle = _htmlentities(trim_characters($nextprev[$type]['body'], 0, 40));
                     if (isset($nextprev[$type]['speaker']) && count($nextprev[$type]['speaker']) > 0) {
                         $linktitle = $nextprev[$type]['speaker']['name'] . ': ' . $linktitle;
                     }
                 } elseif (isset($nextprev[$type]['hdate'])) {
                     $linktitle = format_date($nextprev[$type]['hdate'], SHORTDATEFORMAT);
                 }
                 $data['header_links'][] = array('rel' => $type, 'title' => $linktitle, 'href' => $nextprev[$type]['url']);
             }
         }
     }
     ////////////////////////////////////////////////////////////
     // Page RSS URL
     if ($DATA->page_metadata($this_page, 'rss')) {
         // If this page has an RSS feed set.
         $data['page_rss_url'] = 'http://' . DOMAIN . WEBPATH . $DATA->page_metadata($this_page, 'rss');
     }
     ////////////////////////////////////////////////////////////
     // Site Navigation Links
     $data['assembly_nav_links'] = array();
     $data['section_nav_links'] = array();
     // Page names mapping to those in metadata.php.
     // Links in the top menu, and the sublinks we see if
     // we're within that section.
     $nav_items = array(array('home'), array('hansard', 'mps', 'peers', 'alldebatesfront', 'wranswmsfront', 'pbc_front', 'calendar_summary'), array('sp_home', 'spoverview', 'msps', 'spdebatesfront', 'spwransfront'), array('ni_home', 'nioverview', 'mlas'), array('wales_home'));
     // We work out which of the items in the top and bottom menus
     // are highlighted - $top_highlight and $bottom_highlight respectively.
     $parent = $DATA->page_metadata($this_page, 'parent');
     if (!$parent) {
         $top_highlight = $this_page;
         $bottom_highlight = '';
         $selected_top_link = $DATA->page_metadata('hansard', 'menu');
         $url = new \URL('hansard');
         $selected_top_link['link'] = $url->generate();
     } else {
         $parents = array($parent);
         $p = $parent;
         while ($p) {
             $p = $DATA->page_metadata($p, 'parent');
             if ($p) {
                 $parents[] = $p;
             }
         }
         $top_highlight = array_pop($parents);
         if (!$parents) {
             // No grandparent - this page's parent is in the top menu.
             // We're on one of the pages linked to by the bottom menu.
             // So highlight it and its parent.
             $bottom_highlight = $this_page;
         } else {
             // This page is not in either menu. So highlight its parent
             // (in the bottom menu) and its grandparent (in the top).
             $bottom_highlight = array_pop($parents);
         }
         $selected_top_link = $DATA->page_metadata($top_highlight, 'menu');
         if (!$selected_top_link) {
             # Just in case something's gone wrong
             $selected_top_link = $DATA->page_metadata('hansard', 'menu');
         }
         $url = new \URL($top_highlight);
         $selected_top_link['link'] = $url->generate();
     }
     if ($top_highlight == 'hansard') {
         $section = 'uk';
         $selected_top_link['text'] = 'UK';
     } elseif ($top_highlight == 'ni_home') {
         $section = 'ni';
         $selected_top_link['text'] = 'NORTHERN IRELAND';
     } elseif ($top_highlight == 'sp_home') {
         $section = 'scotland';
         $selected_top_link['text'] = 'SCOTLAND';
     } else {
         $section = '';
     }
     $nav_highlights = array('top' => $top_highlight, 'bottom' => $bottom_highlight, 'top_selected' => $selected_top_link, 'section' => $section);
     //get the top and bottom links
     foreach ($nav_items as $bottompages) {
         $toppage = array_shift($bottompages);
         // Generate the links for the top menu.
         // What gets displayed for this page.
         $menudata = $DATA->page_metadata($toppage, 'menu');
         $text = $menudata['text'];
         $title = $menudata['title'];
         if (!$title) {
             continue;
         }
         //get link and description for the menu ans add it to the array
         $class = $toppage == $nav_highlights['top'] ? 'on' : '';
         $URL = new \URL($toppage);
         $top_link = array('href' => $URL->generate(), 'title' => $title, 'classes' => $class, 'text' => $text);
         array_push($data['assembly_nav_links'], $top_link);
         if ($toppage == $nav_highlights['top']) {
             // This top menu link is highlighted, so generate its bottom menu.
             foreach ($bottompages as $bottompage) {
                 $menudata = $DATA->page_metadata($bottompage, 'menu');
                 $text = $menudata['text'];
                 $title = $menudata['title'];
                 // Where we're linking to.
                 $URL = new \URL($bottompage);
                 $class = $bottompage == $nav_highlights['bottom'] ? 'on' : '';
                 $data['section_nav_links'][] = array('href' => $URL->generate(), 'title' => $title, 'classes' => $class, 'text' => $text);
             }
         }
     }
     $data['assembly_nav_current'] = $nav_highlights['top_selected']['text'];
     ////////////////////////////////////////////////////////////
     // User Navigation Links
     $data['user_nav_links'] = array();
     // We may want to send the user back to this current page after they've
     // joined, logged out or logged in. So we put the URL in $returl.
     $URL = new \URL($this_page);
     $returl = $URL->generate('none');
     //user logged in
     if ($THEUSER->isloggedin()) {
         // The 'Edit details' link.
         $menudata = $DATA->page_metadata('userviewself', 'menu');
         $edittext = $menudata['text'];
         $edittitle = $menudata['title'];
         $EDITURL = new \URL('userviewself');
         if ($this_page == 'userviewself' || $this_page == 'useredit' || $top_highlight == 'userviewself') {
             $editclass = 'on';
         } else {
             $editclass = '';
         }
         // The 'Log out' link.
         $menudata = $DATA->page_metadata('userlogout', 'menu');
         $logouttext = $menudata['text'];
         $logouttitle = $menudata['title'];
         $LOGOUTURL = new \URL('userlogout');
         if ($this_page != 'userlogout') {
             $LOGOUTURL->insert(array("ret" => $returl));
             $logoutclass = '';
         } else {
             $logoutclass = 'on';
         }
         $username = $THEUSER->firstname() . ' ' . $THEUSER->lastname();
         $data['user_nav_links'][] = array('href' => $LOGOUTURL->generate(), 'title' => $logouttitle, 'classes' => $logoutclass, 'text' => $logouttext);
         $data['user_nav_links'][] = array('href' => $EDITURL->generate(), 'title' => $edittitle, 'classes' => $editclass, 'text' => $edittext);
         $data['user_nav_links'][] = array('href' => $EDITURL->generate(), 'title' => $edittitle, 'classes' => $editclass, 'text' => _htmlentities($username));
     } else {
         // User not logged in
         // The 'Join' link.
         $menudata = $DATA->page_metadata('userjoin', 'menu');
         $jointext = $menudata['text'];
         $jointitle = $menudata['title'];
         $JOINURL = new \URL('userjoin');
         if ($this_page != 'userjoin') {
             if ($this_page != 'userlogout' && $this_page != 'userlogin') {
                 // We don't do this on the logout page, because then the user
                 // will return straight to the logout page and be logged out
                 // immediately!
                 $JOINURL->insert(array("ret" => $returl));
             }
             $joinclass = '';
         } else {
             $joinclass = 'on';
         }
         // The 'Log in' link.
         $menudata = $DATA->page_metadata('userlogin', 'menu');
         $logintext = $menudata['text'];
         $logintitle = $menudata['title'];
         $LOGINURL = new \URL('userlogin');
         if ($this_page != 'userlogin') {
             if ($this_page != "userlogout" && $this_page != "userpassword" && $this_page != 'userjoin') {
                 // We don't do this on the logout page, because then the user
                 // will return straight to the logout page and be logged out
                 // immediately!
                 // And it's also silly if we're sent back to Change Password.
                 // And the join page.
                 $LOGINURL->insert(array("ret" => $returl));
             }
             $loginclass = '';
         } else {
             $loginclass = 'on';
         }
         $data['user_nav_links'][] = array('href' => $LOGINURL->generate(), 'title' => $logintitle, 'classes' => $loginclass, 'text' => $logintext);
         $data['user_nav_links'][] = array('href' => $JOINURL->generate(), 'title' => $jointitle, 'classes' => $joinclass, 'text' => $jointext);
     }
     // If the user's postcode is set, then we add a link to Your MP etc.
     if ($THEUSER->postcode_is_set()) {
         $items = array('yourmp');
         if (postcode_is_scottish($THEUSER->postcode())) {
             $items[] = 'yourmsp';
         } elseif (postcode_is_ni($THEUSER->postcode())) {
             $items[] = 'yourmla';
         }
         foreach ($items as $item) {
             $menudata = $DATA->page_metadata($item, 'menu');
             $logintext = $menudata['text'];
             $URL = new \URL($item);
             $data['user_nav_links'][] = array('href' => $URL->generate(), 'title' => '', 'classes' => '', 'text' => $logintext);
         }
     }
     ////////////////////////////////////////////////////////////
     // Search URL
     $SEARCH = new \URL('search');
     $SEARCH->reset();
     $data['search_url'] = $SEARCH->generate();
     ////////////////////////////////////////////////////////////
     // Search URL
     // Footer Links
     $data['footer_links']['about'] = self::get_menu_links(array('help', 'about', 'linktous', 'houserules', 'blog', 'news', 'contact', 'privacy'));
     $data['footer_links']['assemblies'] = self::get_menu_links(array('hansard', 'sp_home', 'ni_home', 'wales_home', 'boundaries'));
     $data['footer_links']['international'] = self::get_menu_links(array('newzealand', 'australia', 'ireland', 'mzalendo'));
     $data['footer_links']['tech'] = self::get_menu_links(array('code', 'api', 'data', 'pombola', 'devmailinglist', 'irc'));
     # banner text
     $b = new Model\Banner();
     $data['banner_text'] = $b->get_text();
     # Robots header
     if (DEVSITE) {
         $data['robots'] = 'noindex,nofollow';
     } elseif ($robots = $DATA->page_metadata($this_page, 'robots')) {
         $data['robots'] = $robots;
     }
     ////////////////////////////////////////////////////////////
     // Unpack the data we've been passed so it's available for use in the templates.
     extract($data);
     ////////////////////////////////////////////////////////////
     // Require the templates and output
     header('Content-Type: text/html; charset=iso-8859-1');
     require_once INCLUDESPATH . 'easyparliament/templates/html/header.php';
     require_once INCLUDESPATH . 'easyparliament/templates/html/' . $template . '.php';
     require_once INCLUDESPATH . 'easyparliament/templates/html/footer.php';
 }
コード例 #10
0
ファイル: hansard_person.php プロジェクト: leowmjw/twfy
// For displaying recent Hansard items for MPs.
// Remember, we are currently within the HANSARDLIST, DEBATELIST or WRANSLISTS class,
// in the render() function.
// The array $data will be packed full of luverly stuff about hansard objects.
// See the bottom of hansard_gid for information about its structure and contents...
global $PAGE, $hansardmajors;
twfy_debug("TEMPLATE", "hansard_person.php");
if (isset($data['rows']) && count($data['rows']) > 0) {
    foreach ($data['rows'] as $n => $row) {
        // While we're linking to individual speeches,
        // the text is the body of the parent, ie (sub)section.
        $text = $row['parent']['body'];
        if (isset($row['listurl'])) {
            // So we can link to the 'More recent appearances' precisely.
            $count = $n + 1;
            $text = "<a name=\"n{$count}\"></a><strong><a href=\"" . $row['listurl'] . "\">{$text}</a></strong> ";
        }
        $text .= '<small>' . format_date($row['hdate'], SHORTDATEFORMAT);
        if ($hansardmajors[$row['major']]['type'] == 'debate') {
            $plural = $row['total_speeches'] == 1 ? 'speech' : 'speeches';
            $text .= ' (' . $row['total_speeches'] . " {$plural})";
        }
        $text .= '</small>';
        $text = "\t\t\t\t<p>{$text}<br />\n\t\t\t\t&#8220;" . trim_characters($row['body'], 0, 200) . "&#8221;</p>\n";
        print $text;
    }
} else {
    ?>
<p>No data to display.</p>
<?php 
}
コード例 #11
0
ファイル: searchlogs.php プロジェクト: palfrey/twfy
<?php

include_once "../../includes/easyparliament/init.php";
include_once INCLUDESPATH . "easyparliament/searchlog.php";
$this_page = "admin_searchlogs";
$PAGE->page_start();
$PAGE->stripe_start();
global $SEARCHLOG;
$search_recent = $SEARCHLOG->admin_recent_searches(50);
$rows = array();
foreach ($search_recent as $row) {
    $host = gethostbyaddr($row['ip_address']);
    $host = trim_characters($host, strlen($host) - 25, 100);
    $time = relative_time($row['query_time']);
    $time = str_replace(" ago", "", $time);
    $rows[] = array('<a href="' . $row['url'] . '">' . htmlentities($row['query']) . '</a>', $row['page_number'], $row['count_hits'], $host, $time);
}
$tabledata = array('header' => array('Query', 'Page', 'Hits', 'Host', 'Time ago'), 'rows' => $rows);
$PAGE->display_table($tabledata);
$menu = $PAGE->admin_menu();
$PAGE->stripe_end(array(array('type' => 'html', 'content' => $menu)));
$PAGE->page_end();
コード例 #12
0
                  <?php 
    if (isset($item['child'])) {
        ?>
                    <p class="business-list__excerpt">
                      <?php 
        if (isset($item['child']['speaker']) && count($item['child']['speaker']) > 0) {
            ?>
                        <a href="<?php 
            echo $item['child']['speaker']['url'];
            ?>
"><?php 
            echo $item['child']['speaker']['name'];
            ?>
</a>
                      <?php 
        }
        ?>
                      <?php 
        echo strip_tags(trim_characters($item['child']['body'], 0, 200));
        ?>
                    </p>
                  <?php 
    }
    ?>
                </li>
              <?php 
}
?>
            </ul>
        </div>
コード例 #13
0
ファイル: trackback.php プロジェクト: udp12/theyworkforyou
 public function add($trackbackdata)
 {
     /*
     $data = array (
         'epobject_id' 	=> '34533',
         'url' 			=> 'http://www.gyford.com/weblog/my_entry.html',
         'blog_name' 	=> "Phil's weblog",
         'title' 		=> 'Interesting speech',
         'excerpt' 		=> 'My MP has posted an interesting speech, etc',
         'source_ip' 	=> '123.123.123.123'
     );
     */
     // This code originally based on stuff from http://wordpress.org/
     if ($this->trackbacks_enabled() == false) {
         $this->_trackback_response(1, 'Sorry, trackbacks are disabled.');
     }
     $epobject_id = $trackbackdata['epobject_id'];
     // Check this epobject_id exists.
     $q = $this->db->query("SELECT epobject_id\n                        FROM\tepobject\n                        WHERE\tepobject_id = '" . addslashes($epobject_id) . "'");
     if ($q->rows() == 0) {
         $this->_trackback_response(1, "Sorry, we don't have a valid epobject_id.");
     }
     // Still here? Then we're trackbacking to a valid hansard item.
     $url = $trackbackdata['url'];
     $source_ip = $trackbackdata['source_ip'];
     // These all strip_tags too.
     $title = trim_characters(html_entity_decode($trackbackdata['title']), 0, 255);
     $excerpt = trim_characters(html_entity_decode($trackbackdata['excerpt']), 0, 255);
     $blog_name = trim_characters(html_entity_decode($trackbackdata['blog_name']), 0, 255);
     $visible = $this->moderate_trackbacks ? 0 : 1;
     $q = $this->db->query("INSERT INTO trackbacks\n                        (epobject_id, blog_name, title, excerpt, url, source_ip, posted, visible)\n                        VALUES\n                        ('" . addslashes($epobject_id) . "',\n                        '" . addslashes($blog_name) . "',\n                        '" . addslashes($title) . "',\n                        '" . addslashes($excerpt) . "',\n                        '" . addslashes($url) . "',\n                        '" . addslashes($source_ip) . "',\n                        NOW(),\n                        '{$visible}')\n                        ");
     if ($q->success()) {
         // Return a success message.
         $this->_trackback_response(0);
     } else {
         die("Sorry, we could not save the trackback to the database. Please <a href=\"mailto:" . CONTACTEMAIL . "\">email us</a> to let us know. Thanks.");
     }
 }
コード例 #14
0
ファイル: single-event.php プロジェクト: XenoEmblems/Alcove
            if (get_post_meta($post->ID, '_cmb_event_time', true) != '') {
                ?>
							<span class="time"><i class="fa fa-clock-o"></i><?php 
                echo get_post_meta($post->ID, '_cmb_event_time', true);
                ?>
</span>
						</div>
						<?php 
            }
            ?>

						<?php 
            if (has_excerpt()) {
                the_excerpt();
            } else {
                echo '<p>' . trim_characters(get_the_content()) . '</p>';
            }
            ?>
						<a href="<?php 
            echo get_permalink();
            ?>
" class="learn-more"><?php 
            _e('Learn More', 'ta-music');
            ?>
</a>
					</div><!-- .event -->
				<?php 
        }
        // end of the loop
        wp_reset_postdata();
    }
コード例 #15
0
ファイル: page.php プロジェクト: archoo/twfy
    function display_commentreportlist($data)
    {
        // For the admin section.
        // Gets an array of data from COMMENTLIST->render().
        // Passes it on to $this->display_table().
        if (count($data) > 0) {
            ?>
			<h3>Reported comments</h3>
<?php 
            // Put the data in an array which we then display using $PAGE->display_table().
            $tabledata['header'] = array('Reported by', 'Begins...', 'Reported on', '');
            $tabledata['rows'] = array();
            $EDITURL = new URL('admin_commentreport');
            foreach ($data as $n => $report) {
                if (!$report['locked']) {
                    // Yes, we could probably cope if we just passed the report_id
                    // through, but this isn't a public-facing page and life's
                    // easier if we have the comment_id too.
                    $EDITURL->insert(array('rid' => $report['report_id'], 'cid' => $report['comment_id']));
                    $editlink = '<a href="' . $EDITURL->generate() . '">View</a>';
                } else {
                    $editlink = 'Locked';
                }
                $body = trim_characters($report['body'], 0, 40);
                $tabledata['rows'][] = array(htmlentities($report['firstname'] . ' ' . $report['lastname']), htmlentities($body), $report['reported'], $editlink);
            }
            $this->display_table($tabledata);
        } else {
            print "<p>There are no outstanding comment reports.</p>\n";
        }
    }
コード例 #16
0
ファイル: glossary.php プロジェクト: leowmjw/twfy
 function glossarise($body, $tokenize = 0, $urlize = 0)
 {
     // Turn a body of text into a link-up wonderland of glossary joy
     global $this_page;
     $findwords = array();
     $replacewords = array();
     $URL = new URL("glossary");
     $URL->insert(array("gl" => ""));
     // External links shown within their own definition
     // should be the complete and linked url.
     // NB. This should only match when $body is a definition beginning with "http:"
     if (is_string($body) && preg_match("/^(http:*[^\\s])\$/i", $body)) {
         $body = "<a href=\"" . $body . "\" title=\"External link to " . $body . "\">" . $body . "</a>";
         return $body;
     }
     // otherwise, just replace everything.
     // generate links from URL when wanted
     // NB WRANS is already doing this
     if ($urlize == 1) {
         $body = preg_replace("~(http(s)?:\\/\\/[^\\s\n]*)\\b(\\/)?~i", "<a href=\"\\0\">\\0</a>", $body);
     }
     // check for any glossary terms to replace
     foreach ($this->replace_order as $glossary_id => $count) {
         if ($glossary_id == $this->glossary_id) {
             continue;
         }
         $term_body = $this->terms[$glossary_id]['body'];
         $term_title = $this->terms[$glossary_id]['title'];
         $URL->update(array("gl" => $glossary_id));
         $findwords[$glossary_id] = "/(?<![>\\.\\'\\/])\\b(" . $term_title . ")\\b(?![<\\'])/i";
         // catch glossary terms within their own definitions
         if ($glossary_id == $this->glossary_id) {
             $replacewords[] = "<strong>\\1</strong>";
         } else {
             if ($this_page == "admin_glossary") {
                 $link_url = "#gl" . $glossary_id;
             } else {
                 $link_url = $URL->generate('url');
             }
             $title = htmlentities(trim_characters($term_body, 0, 80));
             $replacewords[] = "<a href=\"{$link_url}\" title=\"{$title}\" class=\"glossary\">\\1</a>";
         }
     }
     // Highlight all occurrences of another glossary term in the definition.
     $body = preg_replace($findwords, $replacewords, $body);
     if (isset($this->glossary_id)) {
         $body = preg_replace("/(?<![>\\.\\'\\/])\\b(" . $this->terms[$this->glossary_id]['title'] . ")\\b(?![<\\'])/i", '<strong>\\1</strong>', $body, 1);
     }
     // Replace any phrases in wikipedia
     // TODO: Merge this code into above, so our gloss and wikipedia
     // don't clash (e.g. URLs getting doubly munged etc.)
     $body = wikipedize($body);
     // Then translate all the title tag codes.
     // (this stops preg replace replacing content in the title tags)
     if ($tokenize == 0) {
         $body = $this->glossarise_titletags($body);
     }
     return $body;
 }
コード例 #17
0
<?php

global $all_news;
// News content is in here
require_once 'editme.php';
$c = 0;
foreach ($all_news as $id => $news_row) {
    if ($c++ == 2) {
        break;
    }
    list($title, $content, $date) = $news_row;
    $url = news_individual_link($date, $title);
    print "<h5><a href=\"{$url}\">" . $title . "</a></h5>";
    print "<p>";
    print trim_characters(news_format_body($content), 0, 250);
    print " <a href=\"{$url}\">Read more...</a>";
    print "</p>";
}
?>

<p>
<a href="/news/index.rdf">Site News as RSS</a></p>
コード例 #18
0
    
    $extrainfo = array();
    
    $plural = $debate['contentcount'] == 1 ? 'speech' : 'speeches';
    $extrainfo[] = $debate['contentcount'] . ' ' . $plural;
    
    if ($debate['totalcomments'] > 0) {
        $plural = $debate['totalcomments'] == 1 ? 'annotation' : 'annotations';
        $extrainfo[] = $debate['totalcomments'] . ' ' . $plural;
    }
    
    $debateline = '<a href="' . $debate['list_url'] . '">';
    if ($debate['parent']['body']) {
        $debateline .= $debate['parent']['body'] . ': ';
    }
    $debateline .= $debate['body'] . '</a> <small>'
        . format_date($debate['hdate'], LONGERDATEFORMAT)
        . '; ' . implode(', ', $extrainfo) 
        . '</small>';
?>
                <dt><?php echo $debateline; ?></dt>
                <dd><?=trim_characters($debate['child']['body'], 0, 200); ?></dd>
<?php
}
?>
                </dl>
<?

}

コード例 #19
0
ファイル: hansard_gid.php プロジェクト: bruno/twfy
function generate_commentteaser(&$row, $major)
{
    // Returns HTML for the one fragment of comment and link for the sidebar.
    // $totalcomments is the number of comments this item has on it.
    // $comment is an array like:
    /* $comment = array (
    		'comment_id' => 23,
    		'user_id'	=> 34,
    		'body'		=> 'Blah blah...',
    		'posted'	=> '2004-02-24 23:45:30',
    		'username'	=> 'phil'
    		)
    	*/
    // $url is the URL of the item's page, which contains comments.
    global $this_page, $THEUSER, $hansardmajors;
    $html = '';
    if ($hansardmajors[$major]['type'] == 'debate' && $hansardmajors[$major]['page_all'] == $this_page) {
        if ($row['totalcomments'] > 0) {
            $comment = $row['comment'];
            // If the comment is longer than the speech body, we want to trim it
            // to be the same length so they fit next to each other.
            // But the comment typeface is smaller, so we scale things slightly too...
            $targetsize = round(strlen($row['body']) * 0.6);
            if ($targetsize > strlen($comment['body'])) {
                // This comment will fit in its entirety.
                $commentbody = $comment['body'];
                if ($row['totalcomments'] > 1) {
                    $morecount = $row['totalcomments'] - 1;
                    $plural = $morecount == 1 ? 'comment' : 'comments';
                    $linktext = "Read {$morecount} more {$plural}";
                }
            } else {
                // This comment needs trimming.
                $commentbody = htmlentities(trim_characters($comment['body'], 0, $targetsize));
                if ($row['totalcomments'] > 1) {
                    $morecount = $row['totalcomments'] - 1;
                    $plural = $morecount == 1 ? 'comment' : 'comments';
                    $linktext = "Continue reading (and {$morecount} more {$plural})";
                } else {
                    $linktext = 'Continue reading';
                }
            }
            $html = '<em>' . htmlentities($comment['username']) . '</em>: ' . prepare_comment_for_display($commentbody);
            if (isset($linktext)) {
                $html .= ' <a href="' . $row['commentsurl'] . '#c' . $comment['comment_id'] . '" title="See any comments posted about this">' . $linktext . '</a>';
            }
            $html .= '<br><br>';
        }
        // 'Add a comment' link.
        if (!$THEUSER->isloggedin()) {
            $URL = new URL('userprompt');
            $URL->insert(array('ret' => $row['commentsurl']));
            $commentsurl = $URL->generate();
        } else {
            $commentsurl = $row['commentsurl'];
        }
        $html .= '<a href="' . $commentsurl . '#addcomment" title="Comment on this"><strong>Add your comment</strong></a>';
        $html = "\t\t\t\t" . '<p class="comment-teaser">' . $html . "</p>\n";
    }
    return $html;
}
コード例 #20
0
ファイル: Header.php プロジェクト: udp12/theyworkforyou
 private function generate_next_prev_link($nextprev, $linktype)
 {
     $link = null;
     if (isset($nextprev[$linktype]) && isset($nextprev[$linktype]['url'])) {
         if (isset($nextprev[$linktype]['body'])) {
             $linktitle = _htmlentities(trim_characters($nextprev[$linktype]['body'], 0, 40));
             if (isset($nextprev[$linktype]['speaker']) && count($nextprev[$linktype]['speaker']) > 0) {
                 $linktitle = $nextprev[$linktype]['speaker']['name'] . ': ' . $linktitle;
             }
         } elseif (isset($nextprev[$linktype]['hdate'])) {
             $linktitle = format_date($nextprev[$linktype]['hdate'], SHORTDATEFORMAT);
         }
         $link = array('rel' => $linktype, 'title' => $linktitle, 'href' => $nextprev[$linktype]['url']);
     }
     return $link;
 }
コード例 #21
0
ファイル: comments_user.php プロジェクト: leowmjw/twfy
*/
global $PAGE, $DATA, $this_page;
if (isset($data['comments']) && count($data['comments']) > 0) {
    $PAGE->stripe_start();
    ?>
				<h4>Most recent comments</h4>
<?php 
    $PAGE->page_links($data);
    $PAGE->stripe_end();
    $stripecount = 0;
    // Used to generate stripes.
    foreach ($data['comments'] as $n => $comment) {
        $stripecount++;
        $style = $stripecount % 2 == 0 ? '1' : '2';
        $PAGE->stripe_start($style);
        $hansardtext = trim_characters($comment['hbody'], 0, 65);
        list($date, $time) = explode(' ', $comment['posted']);
        $date = format_date($date, SHORTDATEFORMAT);
        // Get the name of the member whose epobject was commented upon (if any).
        if (isset($comment['speaker']) && $comment['speaker']['first_name'] != '') {
            $member_name = $comment['speaker']['first_name'] . ' ' . $comment['speaker']['last_name'] . ': ';
        } else {
            $member_name = '';
        }
        $user_name = htmlentities($comment['firstname'] . ' ' . $comment['lastname']);
        // We're grouping things by epobject_id, so we're going to display the number
        // of comments on this epobject.
        $plural = $comment['total_comments'] == 1 ? ' comment' : ' comments';
        echo "\t\t\t\t<p><a href=\"{$comment['url']}\">{$comment['total_comments']}{$plural}</a> to <strong>" . $member_name . $hansardtext . "</strong><br>\n";
        echo "\t\t\t\t<small>(posted on {$date})</small><br>\n";
        echo "\t\t\t\t" . prepare_comment_for_display($comment['body']) . "</p>";
コード例 #22
0
ファイル: reps.php プロジェクト: nallachaitu/writetothem
debug("FRONTEND", "postcode is $fyr_postcode");
fyr_rate_limit(array('postcode' => array($fyr_postcode, "Postcode that's been typed in"), 
                     'who' => array($fyr_who, "Representative id from DaDem")));

// What to do
$action = get_http_var('action');
if ($action == "") $action = "index";

// Look up info about the representative who is using the interface
$representative = dadem_get_representative_info($fyr_who);
$voting_area = mapit_get_voting_area_info($representative['voting_area']);

// Add extra fields
$newmessages = array();
foreach ($messages as $message) {
    $message['short_body'] = trim_characters($message['body'], 0, 200);
    $message['url'] = "reps?action=forward&id=" . $message['id'];
    $newmessages[] = $message;
}
$messages = $newmessages;

// Perform specified action
if ($action == 'index') {
    // Display page, using all the variables set above.
   template_draw("reps-index", array("representative" => $representative, 
        "voting_area" => $voting_area, 
        "messages" => $messages));
} else {
    $id = get_http_var('id');
    $constituent = $messages[$id];
    $message = $messages[$id];
コード例 #23
0
        $title = $row['parent']['body'];
        if (isset($row['listurl'])) {
            $title = "<a href=\"" . $row['listurl'] . "\">{$title}</a>";
        }
        if (isset($row['speaker']) && isset($row['speaker']['member_id'])) {
            $URL = new URL('member');
            $URL->insert(array('id' => $row['speaker']['member_id']));
            $member = '<a href="' . $URL->generate() . '">' . $row['speaker']['first_name'] . ' ' . $row['speaker']['last_name'] . '</a>: ';
        } else {
            $member = '';
        }
        ?>
						<li><p><strong><?php 
        echo $title;
        ?>
</strong><br>
							<?php 
        echo $member;
        ?>
&#8220;<?php 
        echo trim_characters($row['body'], 0, 200);
        ?>
&#8221;</p></li>
<?php 
    }
    ?>
						</ol>
<?php 
    $PAGE->block_end();
}
// End display of rows.
コード例 #24
0
ファイル: pbc_bill.php プロジェクト: vijo/theyworkforyou
        if (isset($row['contentcount'])) {
            ?>
                                <p class="business-list__meta">
                                    <?php 
            echo $row['contentcount'] == 1 ? '1 speech' : $row['contentcount'] . ' speeches';
            ?>
                                </p>
                            <?php 
        }
        ?>
                            <?php 
        if (isset($row['excerpt'])) {
            ?>
                                <p class="business-list__excerpt">
                                    <?php 
            echo trim_characters($row['excerpt'], 0, 200);
            ?>
                                </p>
                            <?php 
        }
        ?>
                        </li>
                    </ul>
                <?php 
    }
}
?>
            </ul>
        </div>

        <?php 
コード例 #25
0
ファイル: hansard_bill.php プロジェクト: udp12/theyworkforyou
         $moreinfo = array();
         $plural = $row['contentcount'] == 1 ? 'speech' : 'speeches';
         $moreinfo[] = $row['contentcount'] . " {$plural}";
         if ($row['totalcomments'] > 0) {
             $plural = $row['totalcomments'] == 1 ? 'annotation' : 'annotations';
             $moreinfo[] = $row['totalcomments'] . " {$plural}";
         }
         if (count($moreinfo) > 0) {
             print "<small>(" . implode(', ', $moreinfo) . ") </small>";
         }
     } else {
         // Nothing in this item, so no link.
         print '<strong>' . $row['body'] . '</strong>';
     }
     if (isset($row['excerpt'])) {
         print "<br>\n\t\t\t\t\t<span class=\"excerpt-debates\">" . trim_characters($row['excerpt'], 0, 200) . "</span>";
     }
     // End a top-level item.
     if ($row['htype'] == '10') {
         $prevlevel = 'top';
         // End a sub-level item.
     } else {
         print "</li>\n";
         $prevlevel = 'sub';
     }
 }
 // End cycling through rows.
 if ($prevlevel == 'sub') {
     // Finish final sub-level list.
     print "\t\t\t\t\t</ul>\n\t\t\t\t\t</li>\n";
 }
コード例 #26
0
 function generate_commentteaser($row)
 {
     // Returns HTML for the one fragment of comment and link for the sidebar.
     // $totalcomments is the number of comments this item has on it.
     // $comment is an array like:
     /* $comment = array (
            'comment_id' => 23,
            'user_id'    => 34,
            'body'        => 'Blah blah...',
            'posted'    => '2004-02-24 23:45:30',
            'username'    => 'phil'
            )
        */
     // $url is the URL of the item's page, which contains comments.
     if ($row['totalcomments'] == 0) {
         return;
     }
     //Add existing annotations
     $comment = $row['comment'];
     // If the comment is longer than the speech body, we want to trim it
     // to be the same length so they fit next to each other.
     // But the comment typeface is smaller, so we scale things slightly too...
     $targetsize = round(strlen($row['body']) * 0.6);
     $linktext = '';
     if ($targetsize > strlen($comment['body'])) {
         // This comment will fit in its entirety.
         $commentbody = $comment['body'];
         if ($row['totalcomments'] > 1) {
             $morecount = $row['totalcomments'] - 1;
             $plural = $morecount == 1 ? 'annotation' : 'annotations';
             $linktext = "Read {$morecount} more {$plural}";
         }
     } else {
         // This comment needs trimming.
         $commentbody = trim_characters($comment['body'], 0, $targetsize, 1000);
         if ($row['totalcomments'] > 1) {
             $morecount = $row['totalcomments'] - 1;
             $plural = $morecount == 1 ? 'annotation' : 'annotations';
             $linktext = "Continue reading (and {$morecount} more {$plural})";
         } else {
             $linktext = 'Continue reading';
         }
     }
     return array('body' => prepare_comment_for_display($commentbody), 'username' => _htmlentities($comment['username']), 'linktext' => $linktext, 'commentsurl' => $row['commentsurl'], 'comment_id' => $comment['comment_id']);
 }
コード例 #27
0
ファイル: mprss.php プロジェクト: bruno/openaustralia-app
    $MPURL->insert(array('pid' => $person_id));
    $mpurl = $MPURL->generate();
    $date = gmdate('Y-m-d');
    $time = gmdate('H:i:s');
    $datenow = $date . 'T' . $time . '+00:00';
    // Prepare the meat of the RSS file.
    $items = '';
    $entries = '';
    if (isset($speeches['rows']) && count($speeches['rows']) > 0) {
        foreach ($speeches['rows'] as $n => $row) {
            // While we're linking to individual speeches,
            // the text is the body of the parent, ie (sub)section.
            $title = htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
            $link = isset($row['listurl']) ? $row['listurl'] : '';
            $link = 'http://' . DOMAIN . $link;
            $description = htmlentities(trim_characters($row['body'], 0, 200));
            $contentencoded = $row['body'];
            $hdate = format_date($row['hdate'], 'Y-m-d');
            if ($row['htime'] != NULL) {
                $htime = format_time($row['htime'], 'H:i:s');
            } else {
                $htime = '00:00:00';
            }
            $date = $hdate . 'T' . $htime . '+00:00';
            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
            $entries .= "<item rdf:about=\"{$link}\">\n\t<title>{$title}</title>\n\t<link>{$link}</link>\n\t<description>{$description}</description>\n\t<content:encoded><![CDATA[{$contentencoded}]]></content:encoded>\n\t<dc:date>{$date}</dc:date>\n</item>\n";
        }
    }
    // Prepare the whole text of the RSS file.
    $rsstext = '<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF
コード例 #28
0
ファイル: hansard_gid.php プロジェクト: udp12/theyworkforyou
            }
        }
        $out[] = $row;
    }
    if (isset($data['subrows'])) {
        foreach ($data['subrows'] as $row) {
            if (isset($row['contentcount']) && $row['contentcount'] > 0) {
                $has_content = true;
            } elseif ($row['htype'] == '11' && $hansardmajors[$row['major']]['type'] == 'other') {
                $has_content = true;
            } else {
                $has_content = false;
            }
            $entry = $row;
            if (isset($row['excerpt'])) {
                $entry['excerpt'] = trim_characters($entry['excerpt'], 0, 200);
            }
            if ($has_content) {
            } else {
                unset($entry['listurl']);
                unset($entry['commentsurl']);
                unset($entry['comment']);
                unset($entry['totalcomments']);
            }
            $out[] = $entry;
        }
    }
    api_output($out);
} else {
    api_error('Nothing');
}
コード例 #29
0
									<h3><a href="<?php 
            echo get_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
"><?php 
            the_title();
            ?>
</a></h3>
									<p>
									<?php 
            if (has_excerpt()) {
                the_excerpt();
            } else {
                echo trim_characters(get_the_content());
            }
            ?>
									</p>
									<a class="btn btn-transparent" href="<?php 
            echo get_permalink();
            ?>
"><?php 
            if (ta_option('btn_read_more') != '') {
                echo ta_option('btn_read_more');
            }
            ?>
</a>
								</div>
							</div>						
						</article>
コード例 #30
0
                                <p class="excerpt__statement">
                                <?php 
    if (isset($recent['child']['speaker']) && count($recent['child']['speaker'])) {
        ?>
                                <a href="<?php 
        echo $recent['child']['speaker']['url'];
        ?>
"><?php 
        echo $recent['child']['speaker']['name'];
        ?>
</a>
                                <?php 
    }
    ?>
                                <?php 
    echo trim_characters($recent['child']['body'], 0, 200);
    ?>
                                </p>
                            </li>
                            <?php 
} else {
    ?>
                            <li class="parliamentary-excerpt">
                            <h3 class="excerpt__title"><?php 
    echo $recent['desc'];
    ?>
</h3>
                                <?php 
    foreach ($recent['data'] as $date => $details) {
        ?>
                                <p class="meta"><?php