Example #1
0
function display_stats_line_house($house, $category, $blurb, $type, $inwhat, $extra_info, $minister, $afterstuff) {
	if ($category == 'wrans_asked_inlastyear' || $category == 'debate_sectionsspoken_inlastyear' || $category =='comments_on_speeches' ||
		$category == 'Lwrans_asked_inlastyear' || $category == 'Ldebate_sectionsspoken_inlastyear' || $category =='Lcomments_on_speeches') {
		if ($extra_info[$category]==0) {
			$blurb = preg_replace('#<a.*?>#', '', $blurb);
			$inwhat = preg_replace('#<\/a>#', '', $inwhat);
		}
	}
	if ($house==2) $inwhat = str_replace('MP', 'Lord', $inwhat);
	print '<li>' . $blurb;
	print '<strong>' . $extra_info[$category];
	if ($type) print ' ' . make_plural($type, $extra_info[$category]);
	print '</strong>';
	print $inwhat;
	if ($minister===2) {
		print ' &#8212; Speakers/ deputy speakers do not ask written questions';
	} elseif ($minister)
		print ' &#8212; Ministers do not ask written questions';
	else {
		$type = ($house==1?'MP':($house==2?'Lord':'MLA'));
		if (!get_http_var('rem') && isset($extra_info[$category . '_quintile'])) {
			print ' &#8212; ';
			$q = $extra_info[$category . '_quintile'];
			if ($q == 0) {
				print 'well above average';
			} elseif ($q == 1) {
				print 'above average';
			} elseif ($q == 2) {
				print 'average';
			} elseif ($q == 3) {
				print 'below average';
			} elseif ($q == 4) {
				print 'well below average';
			} else {
				print '[Impossible quintile!]';
			}
			print ' amongst ';
			print $type . 's';
		} elseif (!get_http_var('rem') && isset($extra_info[$category . '_rank'])) {
			print ' &#8212; ';
			#if (isset($extra_info[$category . '_rank_joint']))
			#	print 'joint ';
			print make_ranking($extra_info[$category . '_rank']) . ' out of ' . $extra_info[$category . '_rank_outof'];
			print ' ' . $type . 's';
		}
	}
	print ".$afterstuff";
	return true;
}
Example #2
0
				'parent'	=> array (
					'body'		=> 'Environment'
				)
			),
			etc.
		)
	);
*/
twfy_debug("TEMPLATE", "hansard_recent_wrans.php");
echo '<dl class="recent-wrans">';
$count = 0;
foreach ($data['data'] as $wran) {
    $count++;
    $extrainfo = array();
    if ($wran['totalcomments'] > 0) {
        $plural = make_plural('annotation', $wran['totalcomments']);
        $totalcomments = '; ' . $wran['totalcomments'] . ' ' . $plural;
    } else {
        $totalcomments = '';
    }
    $speaker = $wran['child']['speaker'];
    echo '<dt><a name="w', $count, '"></a><strong><a href="', $wran['list_url'], '">';
    if ($wran['parent']['body']) {
        echo $wran['parent']['body'], ': ';
    }
    echo $wran['body'], '</a></strong> <small>(', format_date($wran['hdate'], LONGDATEFORMAT), $totalcomments, ')</small></dt><dd>';
    if (sizeof($speaker)) {
        echo '<a href="', $speaker['url'], '">', member_full_name($speaker['house'], $speaker['title'], $speaker['first_name'], $speaker['last_name'], $speaker['constituency']), '</a>: ';
    }
    echo $wran['child']['body'];
    echo '</dd>';
Example #3
0
 function criteria_pretty($html = false)
 {
     $criteria = explode(' ', $this->criteria);
     $words = array();
     $spokenby = '';
     foreach ($criteria as $c) {
         if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
             $MEMBER = new MEMBER(array('person_id' => $m[1]));
             $spokenby = $MEMBER->full_name();
         } else {
             $words[] = $c;
         }
     }
     $criteria = '';
     if (count($words)) {
         $criteria .= ($html ? '<li>' : '* ') . 'Containing the ' . make_plural('word', count($words)) . ': ' . join(' ', $words) . ($html ? '</li>' : '') . "\n";
     }
     if ($spokenby) {
         $criteria .= ($html ? '<li>' : '* ') . "Spoken by {$spokenby}" . ($html ? '</li>' : '') . "\n";
     }
     return $criteria;
 }
Example #4
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>
<?
        }

    }
Example #5
0
 function query_description_internal($long)
 {
     global $PAGE, $hansardmajors;
     if (!defined('XAPIANDB') || !XAPIANDB) {
         return '';
     }
     $description = "";
     if (count($this->words) > 0) {
         if ($long and $description == "") {
             $description .= " containing";
         }
         $description .= " the " . make_plural("word", count($this->words));
         $description .= " '";
         if (count($this->words) > 2) {
             $description .= join("', '", array_slice($this->words, 0, -2));
             $description .= "', '";
             $description .= $this->words[count($this->words) - 2] . "', and '" . $this->words[count($this->words) - 1];
         } elseif (count($this->words) == 2) {
             $description .= $this->words[0] . "' and '" . $this->words[1];
         } else {
             $description .= $this->words[0];
         }
         $description .= "'";
     }
     if (count($this->phrases) > 0) {
         if ($description == "") {
             if ($long) {
                 $description .= " containing";
             }
         } else {
             $description .= " and";
         }
         $description .= " the " . make_plural("phrase", count($this->phrases)) . " ";
         $description .= join(', ', array_map(array($this, "make_phrase"), $this->phrases));
     }
     if (count($this->excluded) > 0) {
         if (count($this->words) > 0 or count($this->phrases) > 0) {
             $description .= " but not";
         } else {
             $description .= " excluding";
         }
         $description .= " the " . make_plural("word", count($this->excluded));
         $description .= " '" . join(' ', $this->excluded) . "'";
     }
     /*        if (count($this->rough) > 0) {
                 if ($description == "") {
                     if ($long) {
                         $description .= " containing ";
                     }
                 }
                 $description .= " roughly words '" . join(' ', $this->rough) . "'";
             } */
     $major = array();
     $speaker = array();
     foreach ($this->prefixed as $items) {
         if ($items[0] == 'speaker') {
             $member = new MEMBER(array('person_id' => $items[1]));
             $name = $member->full_name();
             $speaker[] = $name;
         } elseif ($items[0] == 'major') {
             if (isset($hansardmajors[$items[1]]['title'])) {
                 $major[] = $hansardmajors[$items[1]]['title'];
             } else {
                 $PAGE->error_message("Unknown major section '{$items['1']}' ignored");
             }
         } elseif ($items[0] == 'groupby') {
             if ($items[1] == 'day') {
                 $description .= ' grouped by day';
             } elseif ($items[1] == 'debate') {
                 $description .= ' grouped by debate/department';
             } elseif ($items[1] == 'speech') {
                 $description .= ' showing all speeches';
             } else {
                 $PAGE->error_message("Unknown group by '{$items['1']}' ignored");
             }
         } elseif ($items[0] == "bias") {
             list($weight, $halflife) = explode(":", $items[1]);
             $description .= " bias by {$weight} halflife {$halflife} seconds";
         } elseif ($items[0] == 'date') {
             $description .= ' spoken on ' . $items[1];
         } elseif ($items[0] == 'batch') {
             # silently ignore, as description goes in email alerts
             #$description .= ' in search batch ' . $items[1];
         } else {
             $PAGE->error_message("Unknown search prefix '{$items['0']}' ignored");
         }
     }
     if (sizeof($speaker)) {
         $description .= ' by ' . join(' or ', $speaker);
     }
     if (sizeof($major)) {
         $description .= ' in ' . join(' or ', $major);
     }
     return trim($description);
 }
    function print_messages($messages, $msgid = null) {
?>

<table border="1" width="100%">
    <tr>
        <th>Created</th>
        <th>Message ID /<br>Group ID</th>
        <th>Last state change</th>
        <th>State /<br>Last action</th>
        <th>Sender</th>
        <th>Recipient</th>
        <th>Client IP / <br> Referrer / Cobrand</th>
        <th>Length (chars)</th>
        <th>Questionnaire</th>
        <th>Tick</th>
    </tr>
    <form action="<?=htmlspecialchars(url_new("", false, 'view', get_http_var('view'), 'simto', get_http_var('simto'), 'page', get_http_var('page'))) ?>" method="post">
<?
            $c = 1;
            foreach ($messages as $message) {
                print '<tr' . ($c==1 ? ' class="v"' : '') . '>';
                print "<td>" . strftime('%Y-%m-%d %H:%M:%S', $message['created']) . "</td>";
                print '<td><a href="'
                        . $this->self_link . "&id=".urlencode($message['id'])
                        . '">'
                        .  $message['id'] . '</a>' 
                        . "<br>${message['group_id']}"
                        . '</td>';
                print "<td>" . strftime('%Y-%m-%d %H:%M:%S', $message['laststatechange']) . "</td>";
                print "<td>";
                print add_tooltip($message['state'], $this->state_help_notes($message['state']));
                /* Only show frozen flag if the message is in a state this can
                 * affect. */
                if ($message['frozen']) 
                {
                    if ($message['state'] == 'new' or $message['state'] == 'pending' or $message['state'] == 'ready')
                        print "<br><b>frozen</b>";
                    else
                        print "<br>frozen";
                }

                if ($message['numactions'] > 0) {
                    if ($message['state'] == 'pending')  {
                        print "<br>" .  ($message['numactions'] - 1) . " ".
                        make_plural(($message['numactions'] - 1), 'reminder');
                    } elseif ($message['state'] == 'sent' || $message['state'] == 'failed_closed')  {
                        print "<br>". $message['numactions'] . " " .
                        make_plural($message['numactions'], 'day');
                    } elseif ($message['state'] == 'ready')  {
                        print "<br>". $message['numactions'] . " " .
                        make_plural($message['numactions'], 'failure');
                    } else {
                        print "<br>". $message['numactions'] . " " .
                        make_plural($message['numactions'], 'attempt');
                    }
                }

                if ($message['lastaction'] > 0 && $message['state'] != 'failed_closed')
                    print "<br>" .  strftime('%Y-%m-%d %H:%M:%S', $message['lastaction']);

                print "</td>";
                print "<td>"
                        . htmlspecialchars($message['sender_name']) . "<br>"
                        . str_replace($message['sender_postcode'], 
                        '<a href="'.OPTION_BASE_URL.'/who?pc='.urlencode($message['sender_postcode']).'">'.$message['sender_postcode'].'</a>',
                            htmlspecialchars($message['sender_addr'])
                                ) . "<br>"
                        . htmlspecialchars($message['sender_email'])
                        . "</td>";

                $display_name = $message['recipient_name'];
                if (!isset($display_name) || $display_name == "") {
                    $display_name = "scrubbed, id " .
                    $message['recipient_id'] . ", " .
                    $message['recipient_type'];
                }
                print '<td><a href="'
                        . htmlspecialchars(url_new('', false, 'page', 'reps', 'rep_id', $message['recipient_id'], 'pc', $message['sender_postcode']))                   . '">' . htmlspecialchars($display_name) . "</a>"
                        . " (<a href=\"" . htmlspecialchars(url_new('', false, 'page', 'fyrqueue', 'rep_id', $message['recipient_id']))                   . '">msgs</a>)' 
                        ."<br>";
                if ($message['recipient_via']) {
                    $repinfo = dadem_get_representative_info($message['recipient_id']);
                    if (!dadem_get_error($repinfo)) {
                        $vainfo = mapit_get_voting_area_info($repinfo['voting_area']);
                        $parentinfo = mapit_get_voting_area_info($vainfo['parent_area_id']);
                        mapit_check_error($parentinfo);
                        print '<a href="' .
                           htmlspecialchars(url_new('', false, 'page', 'reps', 'ds_va_id', $vainfo['parent_area_id'], 'pc', $message['sender_postcode']))  . '">' . 
                            htmlspecialchars("via " . $parentinfo['name']) . "</a>:<br>";
                    } else {
                        print 'recipient_via contact, but rep id not found ';
                    }
                }
                if ($message['recipient_email'])
                    print htmlspecialchars($message['recipient_email']) . "<br>";
                if ($message['recipient_fax'])
                    print htmlspecialchars($message['recipient_fax']) . "<br>";
                print "</td>";

                print "<td><a href=\"ipaddrinfo.cgi?ipaddr=${message['sender_ipaddr']}\">${message['sender_ipaddr']}</a>".
                    "<br>" . trim_url($message['sender_referrer']) . 
                    "<br>" . $message['cobrand'] . " " . $message['cocode'] .
                    "</td>";
                print "<td>${message['message_length']}</td>";

                $outof0 = ($message['questionnaire_0_no'] + $message['questionnaire_0_yes']);
                $outof1 = ($message['questionnaire_1_no'] + $message['questionnaire_1_yes']);
                print '<td>';
                if ($outof0) {
                    print 'responded:';
                    print $message['questionnaire_0_yes'] .'/'. $outof0;
                }
                if ($outof0 && $outof1)
                    print '<br>';
                if ($outof1) {
                    print ' firsttime:';
                    print $message['questionnaire_1_yes'] .'/'. $outof1;
                }
                if ($message['no_questionnaire']) {
                        print "<br>no quest";
                }
                if (!$outof0 && !$outof1) {
                    print '&nbsp;';
                }
                print '</td>';

                /* Javascript code changes shading of table row for checked
                 * messages to make them look "selected". */
                print '<td><input type="checkbox" name="check_'
                        . $message['id']
                        . '" onclick="this.parentNode.parentNode.className = this.checked ? \'h\' : \''
                            . ($c == 1 ? 'v' : '')
                            . '\'" >';
                print '</td>';

                print "</tr>";
                # this.checked this .className=

                if (array_key_exists('diff', $message)) {
                    /* Each element of the array consists either of an array of
                     * two strings, which are the strings unique to the "from"
                     * and "to" strings; or a string, representing a common
                     * part; or null, indicating an elided part. */
                    print '<tr'.($c==1?' class="v"':'').'><td colspan = "9">';
                    print "<b>Differences: </b> ";
                    if (isset($msgid) and $message['id'] == $msgid) {
                        print 'This is the message being compared against. <span class="difffrom">Text that appears only in this message, </span><span class="diffto">or only in the other message.</span>';
                    } else {
                        foreach ($message['diff'] as $elem) {
                            if (!isset($elem)) {
                                print '<span class="diffsnipped">[ ... snipped ... ]</span>';
                            } else if (is_array($elem)) {
                                print '<span class="difffrom">'
                                        . htmlspecialchars($elem[0])
                                        . '</span><span class="diffto">'
                                        . htmlspecialchars($elem[1])
                                        . '</span>';
                            } else {
                                print htmlspecialchars($elem);
                            }
                        }
                    }
                    print "</td></tr>";
                }

                $c = 1 - $c;
            }
            if (count($messages) > 1) {
?><tr><td colspan=9><b>Ticked items:</b>
        <input name="token" value="<? print get_token(); ?>" type="hidden" />
        <input size="20" name="notebody" type="text" /> 
        <input name="note" value="Note" type="submit" />
        &nbsp; <b>Action:</b>
        <input name="freeze" value="Freeze" type="submit" />
        <input name="thaw" value="Thaw" type="submit" />
        <input name="error" value="Error with email" type="submit" />
        <input name="failed" value="Fail silently" type="submit" />
</td><tr>
<?
    }
?>
</form>
</table>
<?
    }
Example #7
0
				'parent'	=> array (
					'body'		=> 'Environment'
				)
			),
			etc.
		)
	);
*/
twfy_debug("TEMPLATE", "hansard_recent_wrans.php");
echo '<dl class="recent-wrans">';
$count = 0;
foreach ($data['data'] as $wran) {
    $count++;
    $extrainfo = array();
    if ($wran['totalcomments'] > 0) {
        $plural = make_plural('comment', $wran['totalcomments']);
        $totalcomments = '; ' . $wran['totalcomments'] . ' ' . $plural;
    } else {
        $totalcomments = '';
    }
    $speaker = $wran['child']['speaker'];
    echo '<dt><a name="w', $count, '"></a><strong><a href="', $wran['list_url'], '">';
    if ($wran['parent']['body']) {
        echo $wran['parent']['body'], ': ';
    }
    echo $wran['body'], '</a></strong> <small>(', format_date($wran['hdate'], LONGDATEFORMAT), $totalcomments, ')</small></dt><dd>';
    if (sizeof($speaker)) {
        echo '<a href="', $speaker['url'], '">', member_full_name($speaker['house'], $speaker['title'], $speaker['first_name'], $speaker['last_name'], $speaker['constituency']), '</a>: ';
    }
    echo $wran['child']['body'];
    echo '</dd>';