Example #1
0
 public function latest_reading_link($args = array())
 {
     $args['ref'] = $this->latest_reading();
     if (!isset($args['name'])) {
         $args['name'] = BibleMeta::name_short;
     }
     if (!isset($args['disable_tooltip'])) {
         $args['disable_tooltip'] = true;
     }
     return bfox_ref_bible_link($args);
 }
function bfox_bp_plan_chart($readings, BfoxReadingSchedule $schedule = null, $user_id = null)
{
    if (empty($max_cols)) {
        $max_cols = 3;
    }
    $reading_cols = bfox_bp_plan_divide_into_cols($readings, $max_cols, 5);
    $date_col = '';
    $date_col_header = '';
    if (!is_null($schedule)) {
        $is_user_member = $user_id && $schedule->is_user_member($user_id);
        $date_col_header = '<th>Date</th>';
    }
    $header = '';
    $rows = array();
    $num_rows = 0;
    foreach ($reading_cols as $col_num => $reading_col) {
        $header .= "<th>#</th>{$date_col_header}<th>Passage</th>";
        $row = 0;
        foreach ($reading_col as $reading_id => $reading) {
            $reading_num = $reading_id + 1;
            $ref_str = bfox_ref_bible_link(array('ref' => $reading, 'name' => BibleMeta::name_short, 'disable_tooltip' => true));
            if (!is_null($schedule)) {
                $date_col = '<td>' . ($is_user_member ? $schedule->reading_checkbox($reading_id) : '') . ' ' . $schedule->reading_date($reading_id, 'M j') . '</td>';
            }
            $rows[$row] .= "<td>{$reading_num}</td>{$date_col}<td>{$ref_str}</td>";
            $row++;
        }
        if ($row > $num_rows) {
            $num_rows = $row;
        } else {
            while ($row < $num_rows) {
                $rows[$row] .= '<td></td><td></td>' . (is_null($schedule) ? '' : '<td></td>');
                $row++;
            }
        }
    }
    $content = "<table><thead><tr>{$header}</tr></thead><tbody>";
    foreach ($rows as $row) {
        $content .= "<tr>{$row}</tr>";
    }
    $content .= '</tbody></table>';
    return $content;
}