コード例 #1
0
 function test_render_with_array_items()
 {
     $items = array(array('label' => 'foo', 'value' => 'bar'), array('label' => 'foo2', 'value' => 'bar2', 'url' => 'quux'), array('label' => 'foo3'), array('label' => 'foo4', 'url' => 'quux2'));
     $block = new SidebarBlock('title', 'description', $items);
     $expected = $this->render_header . '<ul>' . '<li class="foo"><span class="label">foo:</span> bar</li>' . '<li class="foo2"><span class="label">foo2:</span> <a href="quux">bar2</a></li>' . '<li><span class="label">foo3</span></li>' . '<li><span class="label"><a href="quux2">foo4</a></span></li>' . '</ul>' . '<p>description</p></div></div>';
     $this->assertEqualIgnoreWS($expected, $block->render());
 }
コード例 #2
0
    function __construct($record, $query, $stats, $url, $vote_url)
    {
        global $USER, $CONF;
        $allow_guest_votes = $CONF['debug'] && !defined('UNIT_TEST');
        $can_vote = $USER->has_right('save_data') || $allow_guest_votes;
        $show_score = $stats['score'] > 0;
        if (!($can_vote || $show_score)) {
            $hidden = 1;
        }
        if ($show_score) {
            $avg = (int) ($stats['score_avg'] * 100);
            $this->msg .= "{$stats['score']} out of {$stats['score_count']} people found this record useful, a rating of {$avg}%.";
        }
        if ($can_vote) {
            $redirect_url = $record['module']->url('index', $url);
            $this->msg .= <<<_EOT_
<form method="post" action="{$vote_url}">
Was this record useful to you? 
<select name="score"><option value="1">Yes</option><option value="0">No</option></select>
<input type="hidden" value="{$url}" name="record">
<input type="hidden" value="{$redirect_url}" name="redirect_url">
<input type="submit" value="Rate">
</form>
_EOT_;
        }
        parent::__construct('Rate this record', $this->msg, NULL, NULL, @$hidden);
    }
コード例 #3
0
 function __construct($title, $description, $labels, $type, $data, $query)
 {
     $items = array();
     $this->selected = array();
     $this->query = $query;
     // use the labels array to set the display order
     foreach ($labels as $name => $label) {
         if (!isset($data[$name]) || $data[$name] == 0) {
             continue;
         }
         $items[] = array('label' => $labels[$name], 'value' => format_number($data[$name]), 'url' => $query->url(array($type => $name), 'page'));
         // store facets that are currently included in the query string
         if ($query->has_criteria(array($type => array($name => 1)))) {
             $this->selected[$labels[$name]] = array('type' => $type, 'name' => $name);
         }
         // for availability: online - set auth warning flag
         if ($name == '30') {
             $this->show_auth_warning = $this->_has_auth_results($query);
         }
     }
     $hidden = empty($items);
     parent::__construct($title, $description, $items, @$this->help[$type], $hidden);
 }
コード例 #4
0
 function __construct($query, $use_fed_search = NULL)
 {
     //### FIXME: this is a hack, the arg is used for tests only
     if (!is_null($use_fed_search)) {
         $this->use_fed_search = $use_fed_search;
     }
     if ($this->use_fed_search) {
         $fed_module = Module::load('fed');
     }
     $items = array();
     foreach ($query->info['components'] as $comp) {
         // restricted collections don't have an active link
         if (@$comp['restricted']) {
             $url = '';
         } else {
             if ($this->use_fed_search) {
                 $url = $fed_module->url('search', '?' . $query->url_query(array('page' => NULL, 'components' => $comp['module']->name)));
             } else {
                 $url = $comp['module']->url('search', '?' . $query->url_query(array('page' => NULL)));
             }
         }
         $items[] = array('label' => $comp['module']->title, 'value' => format_number($comp['total']), 'url' => $url);
     }
     parent::__construct('Collections', '', $items);
 }