/** * @brief Default constructor. */ function __construct() { parent::__construct('frames/public_frame.php'); $this->mDataArray['description'] = ''; $this->mDataArray['keywords'] = ''; $this->mTitleSet = FALSE; $this->mDataArray['login'] = array('logged_in' => FALSE); $CI =& get_instance(); if ($CI->user_auth->isLoggedIn) { $this->mDataArray['login']['logged_in'] = TRUE; $this->mDataArray['login']['username'] = $entity_id = $CI->user_auth->username; } $this->mDataArray['uri'] = $CI->uri->uri_string(); $CI->load->library('academic_calendar'); $academic_time = new Academic_time(mktime()); $this->mDataArray['date'] = array('time' => date('H:i'), 'day' => date('l'), 'week' => $academic_time->AcademicWeek(), 'date' => date('jS'), 'month' => date('F')); $CI->load->model('ticker_model'); $this->mDataArray['ticker'] = $CI->ticker_model->getNews(); // Get user's Links $CI->load->model('links_model'); if ($CI->user_auth->isLoggedIn) { $this->mDataArray['links'] = $CI->links_model->GetFormattedLinks($CI->user_auth->entityId); } else { $this->mDataArray['links'] = $CI->links_model->GetFormattedLinks(0); } }
<div><?php ?> be one of the first to complete a crossword online and have your name on the winner list!<?php ?> </div><?php } else { if (!empty($next)) { ?> <div class="Date"><?php echo 'next online crossword will be published ' . xml_escape($next_pub_text); ?> </div><?php } foreach ($latest as $crossword) { $pub = new Academic_time($crossword['publication']); $pub_text = $pub->Format('D') . ' week ' . $pub->AcademicWeek() . ' ' . $pub->Format('H:i'); ?> <div style="width:50%;float:left;"><?php // Icon and category ?> <a href="<?php echo site_url('crosswords/' . $crossword['id']); ?> "><?php ?> <img alt="" src="<?php echo site_url('crosswords/' . $crossword['id'] . '/preview'); ?> " /><?php echo xml_escape($crossword['category_name']); ?>
private function _fillTipsFeed($category_id = null, $limit = 20) { $this->load->library('academic_calendar'); $channel =& $this->main_frame->Channel(); $channel->SetImage('http://' . $_SERVER['HTTP_HOST'] . '/images/crosswords/xw.png', 64, 64); $channel->SetEditor('crosswords@theyorker.co.uk (crosswords editor)'); $channel->SetWebmaster('webmaster@theyorker.co.uk (webmaster)'); $tips = $this->crosswords_model->GetTips($category_id, null, null, true); $url = 'http://' . $_SERVER['HTTP_HOST']; foreach ($tips as &$tip) { $item =& $channel->NewItem(); $item->SetPublicationDate($tip['publication']); $pub = new Academic_time($tip['publication']); $pub_str = $pub->Format('D ') . $pub->AcademicTermNameUnique() . ' week ' . $pub->AcademicWeek(); $title = '(' . $tip['category_name'] . ') ' . $pub_str; $item->SetTitle($title); $item->AddCategory($tip['category_name']); $item->SetLink($url . '/crosswords/' . (int) $tip['crossword_id'] . '#tip' . (int) $tip['id']); $item->SetDescription($tip['content_xhtml']); } }
/** * @param $NumToGet int Number of comments to return * @author Chris Travis (cdt502 - ctravis@gmail.com) */ function GetLatestComments($NumToGet = 10) { $ci =& get_instance(); $ci->load->model('crosswords_model'); $ci->load->library('academic_calendar'); $article_sql = 'SELECT comments.comment_id, comments.comment_anonymous, UNIX_TIMESTAMP(comments.comment_post_time) AS comment_post_time, comments.comment_content_wikitext, users.user_firstname, users.user_surname, article_contents.article_content_heading AS heading, UNIX_TIMESTAMP(articles.article_publish_date) AS publication, ( SELECT COUNT(*) FROM comments AS article_comments WHERE article_comments.comment_comment_thread_id = comments.comment_comment_thread_id AND article_comments.comment_post_time <= comments.comment_post_time ) AS article_comment_count, 1 AS source FROM articles, comments, users, article_contents, content_types WHERE comments.comment_deleted = 0 AND comments.comment_comment_thread_id = articles.article_public_comment_thread_id AND articles.article_publish_date < CURRENT_TIMESTAMP AND articles.article_pulled = 0 AND articles.article_deleted = 0 AND articles.article_live_content_id IS NOT NULL AND articles.article_live_content_id = article_contents.article_content_id AND articles.article_content_type_id = content_types.content_type_id AND comments.comment_author_entity_id = users.user_entity_id'; $crossword_sql = 'SELECT comments.comment_id, comments.comment_anonymous, UNIX_TIMESTAMP(comments.comment_post_time) AS comment_post_time, comments.comment_content_wikitext, users.user_firstname, users.user_surname, crossword_categories.crossword_category_name AS heading, UNIX_TIMESTAMP(crosswords.crossword_publication) AS publication, ( SELECT COUNT(*) FROM comments AS article_comments WHERE article_comments.comment_comment_thread_id = comments.comment_comment_thread_id AND article_comments.comment_post_time <= comments.comment_post_time ) AS article_comment_count, 2 AS source FROM comments INNER JOIN users ON users.user_entity_id = comments.comment_author_entity_id INNER JOIN crosswords ON comments.comment_comment_thread_id = crosswords.crossword_public_comment_thread_id AND ' . $ci->crosswords_model->published_sql . ' AND ' . $ci->crosswords_model->expired_sql . ' INNER JOIN crossword_categories ON crossword_categories.crossword_category_id = crosswords.crossword_category_id WHERE comments.comment_deleted = 0'; $sql = "({$article_sql}) UNION ({$crossword_sql})\n\t\t\t\tORDER BY comment_post_time DESC\n\t\t\t\tLIMIT\t0, ?"; $query = $this->db->query($sql, array($NumToGet)); $results = $query->result_array(); foreach ($results as &$result) { if ($result['source'] == 2) { $pub = new Academic_time($result['publication']); $pub_date = $pub->Format('D') . ' week ' . $pub->AcademicWeek(); $result['heading'] = $result['heading'] . ', ' . $pub_date; } } return $results; }
<?php /** * @file views/crosswords/category.php * @author James Hogan <*****@*****.**> * @param $Category category. * @param $Links array */ ?> <div class="BlueBox"><?php if (count($Category['next']) > 0) { $pub = new Academic_time($Category['next'][0]['publication']); ?> <div class="crossword_note"><?php echo 'next: ' . $pub->Format('D') . ' week ' . $pub->AcademicWeek() . $pub->Format(' H:i'); ?> </div><?php } if (count($Category['latest']) > 0) { ?> <div class="crossword_note"><?php ?> <a href="<?php echo site_url('crosswords/' . $Category['short_name'] . '/archive'); ?> ">archive</a><?php ?> </div><?php } ?> <h2><?php
protected function _Load() { $value = $this->value; if (null === $value) { $value = Academic_time::NewToday(); } else { $value = new Academic_time($value); } ?> <div class="input_date_display"<?php ?> onclick="<?php echo xml_escape('return input_date_click("' . $this->name . '");'); ?> "<?php ?> ><?php if ($this->date) { ?> <span class="day" id="<?php echo $this->id . '__day'; ?> "><?php echo $value->Format('l'); ?> </span> <?php ?> week <span class="week" id="<?php echo $this->id . '__wk'; ?> "><?php echo $value->AcademicWeek(); ?> </span> <?php ?> of <span class="term" id="<?php echo $this->id . '__term'; ?> "><?php echo ucfirst($value->AcademicTermNameUnique()); echo ' ' . $value->StartOfTerm()->Year(); ?> </span> <?php } if ($this->time) { ?> at <span class="hour" id="<?php echo $this->id . '__hr'; ?> "><?php echo $value->Hour(); ?> </span><?php ?> :<span class="minute" id="<?php echo $this->id . '__min'; ?> "><?php echo $value->Minute(); ?> </span> <?php } ?> </div><?php $days = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); ?> <div class="input_date_selector"<?php ?> id="<?php echo $this->id . '__selector'; ?> "<?php ?> ><?php // Init script ?> <script type="text/javascript"><?php echo xml_escape('onLoadFunctions.push(function() {' . 'input_date_init(' . js_literalise($this->name) . ');' . '});', false); ?> </script><?php ?> <div><?php // Day of the week ?> <select id="<?php echo $this->id . '__day_select'; ?> "<?php ?> name="<?php echo $this->name . '[day]'; ?> "<?php ?> onchange="<?php echo xml_escape('return input_date_day_changed("' . $this->name . '");'); ?> "<?php ?> ><?php foreach ($days as $val => $day) { ?> <option value="<?php echo $val; ?> "<?php if ($val == $value->DayOfWeek(1)) { ?> selected="selected"<?php } ?> ><?php echo $day; ?> </option><?php } ?> </select><?php // Week of the term ?> <span>week</span><?php ?> <select id="<?php echo $this->id . '__wk_select'; ?> "<?php ?> name="<?php echo $this->name . '[wk]'; ?> "<?php ?> onchange="<?php echo xml_escape('return input_date_day_changed("' . $this->name . '");'); ?> "<?php ?> ><?php $weeks = $value->AcademicTermWeeks(); for ($wk = 1; $wk <= $weeks; ++$wk) { ?> <option value="<?php echo $wk; ?> "<?php if ($wk == $value->AcademicWeek()) { ?> selected="selected"<?php } ?> ><?php echo $wk; ?> </option><?php } ?> </select><?php // Term ?> <span>of</span><?php ?> <select id="<?php echo $this->id . '__term_select'; ?> "<?php ?> name="<?php echo $this->name . '[term]'; ?> "<?php ?> onchange="<?php echo xml_escape('return input_date_term_changed("' . $this->name . '");'); ?> "<?php ?> ><?php $sel_year = $value->AcademicYear(); $sel_term = $value->AcademicTerm(); $year = $sel_year; $term = 0; ?> <option value="earlier">(more)</option><?php for ($i = 0; $i < 6; ++$i) { $cur = new Academic_time(Academic_time::StartOfAcademicTerm($year, $term)); ?> <option value="<?php echo "{$year}-{$term}"; ?> "<?php if ($term == $sel_term && $year == $sel_year) { ?> selected="selected"<?php } ?> ><?php echo xml_escape(ucfirst($cur->AcademicTermNameUnique()) . ' ' . $cur->Year()); ?> </option><?php ++$term; if ($term == 6) { $term = 0; ++$year; } } ?> <option value="later">(more)</option><?php ?> </select><?php // Time of day if ($this->time) { ?> <span>at</span><?php ?> <select id="<?php echo $this->id . '__hr_select'; ?> "<?php ?> name="<?php echo $this->name . '[hr]'; ?> "<?php ?> onchange="<?php echo xml_escape('return input_date_time_changed("' . $this->name . '");'); ?> "<?php ?> ><?php for ($hr = 0; $hr < 24; ++$hr) { ?> <option value="<?php echo $hr; ?> "<?php if ($hr == $value->Hour()) { ?> selected="selected"<?php } ?> ><?php echo sprintf('%02d', $hr); ?> </option><?php } ?> </select><?php ?> <span>:</span><?php ?> <select id="<?php echo $this->id . '__min_select'; ?> "<?php ?> name="<?php echo $this->name . '[min]'; ?> "<?php ?> onchange="<?php echo xml_escape('return input_date_time_changed("' . $this->name . '");'); ?> "<?php ?> ><?php $minute = $value->Minute(); $minute_interval = 5; for ($min = 0; $min < 60; $min += $minute_interval) { ?> <option value="<?php echo $min; ?> "<?php if ($min <= $minute && $min + $minute_interval > $minute) { ?> selected="selected"<?php } ?> ><?php echo sprintf('%02d', $min); ?> </option><?php } ?> </select><?php } // Close button ?> <input type="button" value="x"<?php ?> onclick="<?php echo xml_escape('return input_selector_click("' . $this->name . '__selector");'); ?> "<?php ?> /><?php ?> </div><?php ?> <div><?php ?> <table class="recur-cal cal-text"><?php // Days along the top ?> <tr><?php ?> <th /><?php foreach ($days as $day) { ?> <th><?php echo xml_escape($day); ?> </th><?php } ?> </tr><?php $cur = $value->MondayWeek1OfTerm(); $sel = $value->Midnight()->Timestamp(); $today = Academic_time::NewToday()->Timestamp(); $last_month = 0; $term = $cur->AcademicTerm(); for ($wk = 1; $cur->AcademicTerm() == $term; ++$wk) { ?> <tr id="<?php echo $this->id . '__wk_' . $wk; ?> "><?php ?> <th><?php echo $wk; ?> </th><?php for ($dy = 0; $dy < 7; ++$dy) { $month = $cur->Month(); $ts = $cur->Timestamp(); $classes = array(); if ($ts < $today) { $classes[] = "pa"; } if ($month % 2 == 0) { $classes[] = "ev"; } if ($ts == $today) { $classes[] = "tod"; } if ($ts == $sel) { $classes[] = "sel"; } if ($dy >= 5) { $classes[] = "we"; } ?> <td class="<?php echo join(' ', $classes); ?> "<?php ?> id="<?php echo $this->id . '__' . $cur->AcademicWeek() . '_' . $cur->Format('D'); ?> "<?php ?> onclick="<?php echo xml_escape('return input_date_change(' . js_literalise($this->name) . ',' . js_literalise($wk) . ',' . js_literalise($dy) . ');'); ?> "<?php ?> ><?php if ($month != $last_month) { echo xml_escape($cur->Format('M')) . ' '; $last_month = $month; } echo xml_escape($cur->Format('j')); ?> </td><?php $cur = $cur->Adjust('+1day'); } ?> </tr><?php } ?> </table><?php ?> </div><?php ?> </div><?php }
?> <div class="crosswordShare"><?php ?> <a href="http://www.facebook.com/share.php?u=http://<?php echo $ShareUrl; ?> " target="_blank" class="fb_share_button" onclick="return fbs_click()">Share</a><?php ?> </div><?php } // Rest of top box ?> <h2><?php if ($Crossword['publication'] !== null) { $pub = new Academic_time($Crossword['publication']); echo $pub->Format('D ') . $pub->AcademicTermNameUnique() . ' week ' . $pub->AcademicWeek(); } else { ?> unscheduled<?php } ?> </h2><?php if (!empty($Links)) { ?> <ul><?php // Main links foreach ($Links as $label => $url) { ?> <li><a href="<?php echo xml_escape($url); ?>
echo site_url('office/crosswords/crossword/' . $crossword['id'] . '/preview?cellsize=3'); ?> " /><?php ?> </a><?php ?> </div><?php // Publishing date ?> <div class="publish_date"><?php if (null === $crossword['publication']) { ?> <a>schedule</a><?php } else { $pub = new Academic_time($crossword['publication']); echo $pub->Format('D') . ' ' . $pub->AcademicTermNameUnique() . ' ' . $pub->AcademicWeek() . $pub->Format(' (jS M Y)') . ' at ' . $pub->Format('H:i'); } ?> </div><?php // Authors ?> <div class="authors"><?php echo xml_escape(join(', ', $crossword['author_fullnames'])); ?> </div><?php // Progress bar ?> <div class="completeness"><?php ?> <div class="bar" style="width: <?php echo (int) $crossword['completeness'] . '%';
function Load() { /// Process the data before loading $this->ProcessEvents($this->mData, $this->mCategories); /// Make some links if (NULL !== $this->mPaths && NULL !== $this->mRangeFormat && NULL !== $this->mStartTime && NULL !== $this->mEndTime) { $days = Academic_time::DaysBetweenTimestamps($this->mStartTime, $this->mEndTime); $start = new Academic_time($this->mStartTime); $end = new Academic_time($this->mEndTime); $now = new Academic_time(time()); $try_again = TRUE; if (0 === $start->AcademicDay() && 0 === $end->AcademicDay()) { $CI =& get_instance(); $terms_apart = ($end->AcademicYear() - $start->AcademicYear()) * 6 + $end->AcademicTerm() - $start->AcademicTerm(); // don't really need to scroll in years if (FALSE && $terms_apart >= 6) { $this->SetData('ForwardUrl', $this->GenerateRangeUrl($CI->academic_calendar->Academic($start->AcademicYear() + 1, $start->AcademicTerm(), $start->AcademicWeek()), $CI->academic_calendar->Academic($end->AcademicYear() + 1, $end->AcademicTerm(), $end->AcademicWeek()))); $this->SetData('BackwardUrl', $this->GenerateRangeUrl($CI->academic_calendar->Academic($start->AcademicYear() - 1, $start->AcademicTerm(), $start->AcademicWeek()), $CI->academic_calendar->Academic($end->AcademicYear() - 1, $end->AcademicTerm(), $end->AcademicWeek()))); $try_again = FALSE; } elseif ($terms_apart > 0) { $this->SetData('ForwardUrl', $this->GenerateRangeUrl($CI->academic_calendar->Academic($start->AcademicYear() + (5 === $start->AcademicTerm() ? 1 : 0), ($start->AcademicTerm() + 1) % 6, $start->AcademicWeek()), $CI->academic_calendar->Academic($end->AcademicYear() + (5 === $start->AcademicTerm() ? 1 : 0), ($end->AcademicTerm() + 1) % 6, $end->AcademicWeek()))); $this->SetData('BackwardUrl', $this->GenerateRangeUrl($CI->academic_calendar->Academic($start->AcademicYear() - (0 === $start->AcademicTerm() ? 1 : 0), ($start->AcademicTerm() + 5) % 6, $start->AcademicWeek()), $CI->academic_calendar->Academic($end->AcademicYear() - (0 === $start->AcademicTerm() ? 1 : 0), ($end->AcademicTerm() + 5) % 6, $end->AcademicWeek()))); $try_again = FALSE; } $this->SetData('NowUrl', $this->GenerateRangeUrl($CI->academic_calendar->Academic($now->AcademicYear(), $now->AcademicTerm(), 1), $CI->academic_calendar->Academic($now->AcademicYear() + (5 === $start->AcademicTerm() ? 1 : 0), ($now->AcademicTerm() + 1) % 6, 1))); $this->SetData('NowUrlLabel', 'This term'); } if ($try_again) { $now = $now->Midnight(); if ($days >= 7) { $forward_jump = '1week'; $now = $now->BackToMonday(); $this->SetData('NowUrlLabel', 'This week'); } else { $forward_jump = '1day'; $this->SetData('NowUrlLabel', 'Today'); } $this->SetData('ForwardUrl', $this->GenerateRangeUrl($start->Adjust($forward_jump), $end->Adjust($forward_jump))); $this->SetData('BackwardUrl', $this->GenerateRangeUrl($start->Adjust('-' . $forward_jump), $end->Adjust('-' . $forward_jump))); $this->SetData('NowUrl', $this->GenerateRangeUrl($now, $now->Adjust('+' . $forward_jump))); } } parent::Load(); }