/** * Format a {@link DATE_TIME} as plain text. * @param DATE_TIME $t * @param integer $type Override the default formatting type. * @return string */ public function time($t, $type = null) { $f = $t->formatter(); $f->clear_flags(); if (isset($type)) { $f->type = $type; } return $t->format($f); }
/** * @param DATABASE $db */ public function load($db) { parent::load($db); $this->branch_id = $db->f('branch_id'); $this->summary = $db->f('summary'); $this->time_next_deadline->set_from_iso($db->f('time_next_deadline')); $this->time_scheduled->set_from_iso($db->f('time_scheduled')); $this->time_shipped->set_from_iso($db->f('time_shipped')); $this->time_testing_scheduled->set_from_iso($db->f('time_testing_scheduled')); $this->time_tested->set_from_iso($db->f('time_tested')); }
protected function _pre_store() { parent::_pre_store(); if (!$this->exists()) { $this->modifier_id = $this->login->id; $this->time_modified->set_now(); $this->creator_id = $this->login->id; $this->time_created->set_now(); } elseif ($this->state != Abandoned) { // Abandoned items should be abandoned "in-place"; the abandoner is retained in the item's history. if ($this->update_modifier_on_change) { $this->modifier_id = $this->login->id; } $this->time_modified->set_now(); } }
/** * Set the first and last days to render. * Must be called before calling {@link display()}. * @param DATE_TIME $first_day * @param DATE_TIME $last_day */ public function set_ranges($first_day, $last_day) { $first_day->set_time_from_iso('00:00:00'); $last_day->set_time_from_iso('23:59:59'); $this->first_day = $first_day; $this->last_day = $last_day; $php_first_day = $first_day->as_php(); $php_last_day = $last_day->as_php(); $first_month = date("n", $php_first_day); $first_year = date("Y", $php_first_day); $last_month = date("n", $php_last_day); $last_year = date("Y", $php_last_day); $diff_months = $last_year * Months_in_year + $last_month - ($first_year * Months_in_year + $first_month); if ($diff_months > Months_in_year) { $this->num_years = $last_year - $first_year + 1; } else { $this->num_years = 1; } $this->pager->set_ranges($this->num_years, 1); $this->pager->page_offset = date("Y", $php_first_day) - 1; $curr_month = $first_month; $curr_year = $first_year; $diff_months = $last_year * 12 + $last_month - ($curr_year * 12 + $curr_month); if ($diff_months > 12) { // the span is more than 12 months, so split into pages if ($this->pager->page_number == 1) { $last_month = 12; $last_year = $curr_year; } else { $curr_month = 1; $curr_year = $curr_year + $this->pager->page_number - 1; if ($curr_year != $last_year) { $last_month = 12; $last_year = $curr_year; } } } $this->_curr_month = $curr_month; $this->_curr_year = $curr_year; $this->_last_month = $last_month; $this->_last_year = $last_year; $this->_page_changed(); }
/** * Show set of user details. * @param string $title * @param USER $user * @param DATE_TIME $date * @access private */ protected function _echo_user_information($title, $user, $date) { ?> <tr> <th><?php echo $title; ?> </th> <td><?php echo $user->title_as_link(); ?> </td> </tr> <tr> <th>Date</th> <td><?php echo $date->format(); ?> </td> </tr> <?php }
/** * Return the needed by status as HTML or plain text. * Returns empty if there is no needed by date. * @param boolean $text_only Do not use HTML tags when formatting. * @return string * @access private */ protected function _needed_by_as_text($text_only) { $Result = ''; $entry = $this->entry(); if ($entry->time_needed->is_valid()) { $rel = $this->release(); if ($rel) { $occurred = new DATE_TIME(); $occurred->clear(); include_once 'projects/obj/release_status.php'; $status = new RELEASE_DATE_STATUS($rel, $occurred, $entry->time_needed); $Result = ''; $diff_as_text = $status->diff_as_text($text_only); $Result .= 'Needed by ' . $status->date_as_text($text_only); if ($diff_as_text) { $Result .= ' (' . $diff_as_text; if ($status->diff_label) { $Result .= ' ' . $status->diff_label . ')'; } else { $Result .= ')'; } } if ($text_only) { if ($status->text) { $Result = $status->text . ' ' . $Result; } } else { $Result = $this->app->get_icon_with_text($status->icon_url, Sixteen_px, $Result); } } } return $Result; }
/** * @param DATABASE $db */ public function load($db) { parent::load($db); $this->location = $db->f('location'); $this->url_root = strtolower($db->f('url_root')); $this->main_picture_id = $db->f('main_picture_id'); $this->show_celsius = $db->f('show_celsius'); $this->show_times = $db->f('show_times'); $this->max_picture_width = $db->f('max_picture_width'); $this->max_picture_height = $db->f('max_picture_height'); $this->first_day_mode = $db->f('first_day_mode'); $this->last_day_mode = $db->f('last_day_mode'); $this->first_day->set_from_iso($db->f('first_day')); if ($this->last_day_mode == Day_mode_today) { $this->last_day->set_now(); } else { $this->last_day->set_from_iso($db->f('last_day')); } }
$tag_validator = $App->make_tag_validator(Tag_validator_multi_line); $tag_validator->validate($newDescription); $errors = array(); if (sizeof($tag_validator->errors)) { $message = 'Input contained errors.'; $message_type = 'error'; foreach ($tag_validator->errors as $error) { $validation_error = new TEXT_VALIDATION_ERROR(); $validation_error->message = sprintf($error->message, $error->token->data()); $validation_error->line_number = $error->line_number; $validation_error->column_start = $error->column; $validation_error->column_end = $error->column + strlen($error->token->data()); $errors[] = $validation_error; } } else { $now = new DATE_TIME(); $now->set_now(); $f = $now->formatter(); $f->type = Date_time_format_date_and_time; $f->clear_flags(); $formatted_text = $munger->transform($newDescription, $obj); $message = 'Preview updated at ' . $now->format($f) . '.'; $message_type = 'info'; } } else { $message = 'Object for that ID was not found.'; $message_type = 'error'; } $message = $App->get_begin_message($message_type) . $message . $App->get_end_message(); $result = array('text' => $formatted_text, 'errors' => $errors, 'message' => $message, 'modified' => $obj->time_modified->as_iso()); echo json_encode($result);
/** * Display a user and date in HTML. * Formatted as: 'caption' by 'user' on 'time' * @param string $caption * @param USER $user * * @param DATE_TIME $time * @access private */ protected function _echo_html_user($caption, $user, $time) { echo "<p>\n"; echo $caption . ' by ' . $user->title_as_link() . ' on ' . $time->format() . "\n"; echo "</p>\n"; }
protected function _pre_store() { parent::_pre_store(); if ($this->unpublished()) { $this->time_published->clear(); $this->publisher_id = 0; if ($this->_state_when_loaded != $this->state) { // State changed; check history items and revoke notification for published items $history_item_query = $this->history_item_query(); /** @var HISTORY_ITEM[] $history_items */ $history_items = $history_item_query->objects(); foreach ($history_items as $history_item) { if ($history_item->kind == History_item_published && $history_item->publication_state == History_item_needs_send) { $history_item->publication_state = History_item_silent; $history_item->store(); } } } } elseif (!$this->time_published->is_valid()) { $this->time_published->set_now(); if ($this->update_modifier_on_change) { $this->publisher_id = $this->login->id; } else { $this->publisher_id = $this->modifier_id; } } }
/** * @param DATABASE $db Database from which to load values. */ public function load($db) { parent::load($db); $this->send_as_html = $db->f('send_as_html'); $this->preferred_text_length = $db->f('preferred_text_length'); $this->send_own_changes = $db->f('send_own_changes'); $this->max_individual_messages = $db->f('max_individual_messages'); $this->max_items_per_message = $db->f('max_items_per_message'); $this->min_hours_to_wait = $db->f('min_hours_to_wait'); $this->group_history_items = $db->f('group_history_items'); $this->show_history_items = $db->f('show_history_items'); $this->show_history_item_as_subject = $db->f('show_history_item_as_subject'); $this->time_messages_sent->set_from_ISO($db->f('time_messages_sent')); $this->queued_history_item_ids = $db->f('queued_history_item_ids'); $this->email = $db->f('email'); $this->_read_only = false; }
public function __construct() { $this->gecko_date = new DATE_TIME(); $this->gecko_date->clear(); }
/** * Draw the given project entry in the list. * * @param PROJECT_ENTRY $entry * @param USER $user * @param DATE_TIME $time * @access private */ protected function _draw_entry($entry, $user, $time) { $this->_draw_component_break($entry); if ($this->show_date) { $f = $time->formatter(); $f->type = Date_time_format_short_date; $details[] = $time->format($f); } if ($this->show_user && isset($user)) { $uf = $user->title_formatter(); $uf->css_class = ''; $details[] = $user->title_as_link($uf); } $detail = ''; if (!empty($details)) { $detail = '[' . implode(' - ', $details) . '] '; } $detail .= $entry->title_as_link(); $props = $entry->kind_properties(); echo '<li>' . $this->context->get_icon_with_text($props->icon, Sixteen_px, $detail); if ($this->show_description) { $munger = $entry->html_formatter(); $munger->force_paragraphs = false; $desc = $entry->description_as_html($munger); if ($desc) { echo "<div class=\"description\">{$desc}</div>"; } } echo '</li>'; }
/** * Values will expire when the browser is closed. */ public function expire_when_session_ends() { $this->expire_date->clear(); }
/** * @param DATABASE $db */ public function load($db) { parent::load($db); $this->date->set_from_iso($db->f('date')); }
/** * Read a time value from the EXIF data block. * Date/times are stored in a non-standard format and must be parsed to create a usable time object. * @param string $exif_time * @return DATE_TIME * @access private */ protected function _time_from_exif($exif_time) { $Result = new DATE_TIME(); $Result->clear(); if ($exif_time) { $exif_pieces = explode(' ', $exif_time); if (sizeof($exif_pieces) == 2) { $d = str_replace(':', '-', $exif_pieces[0]); $t = trim($exif_pieces[1]); } $Result->set_from_iso($d . ' ' . $t); } return $Result; }
/** * @param DATABASE $db */ public function load($db) { parent::load($db); $this->time_applied->set_from_iso($db->f('branch_time_applied')); $this->applier_id = $db->f('branch_applier_id'); }
/** * @param FORM_RENDERER $renderer * @access private */ protected function _draw_controls($renderer) { $renderer->start(); $renderer->draw_text_line_row('title'); $renderer->draw_check_box_row('is_visible'); $this->_draw_kind_controls($renderer); $this->_draw_component_controls($renderer); // Start the branch section $this->_draw_branch_controls($renderer); $renderer->draw_submit_button_row(); $renderer->draw_text_box_row('description'); $renderer->draw_text_box_row('files'); $renderer->draw_submit_button_row(); $renderer->draw_text_box_row('extra_description'); $branch_id = $this->value_for('main_branch_id'); /** @var $folder PROJECT */ $folder = $this->_folder; $branch_query = $folder->branch_query(); /** @var $branch BRANCH */ $branch = $branch_query->object_at_id($branch_id); $release_id = $this->value_for("branch_{$branch_id}_release_id"); if ($release_id) { $release_query = $branch->release_query(); $release = $release_query->object_at_id($release_id); $entry_query = $release->entry_query(); } else { $entry_query = $branch->entry_query(); } $entry_query->set_type('job'); if ($this->object_exists()) { $t = $this->_object->time_created; } else { $t = new DATE_TIME(); } $job_id = $this->value_for('job_id'); if (empty($job_id)) { $job_id = 0; } $entry_query->restrict("(entry.id = {$job_id}) OR (closer_id <> 0) <> 0 OR (job.time_closed < '" . $t->as_iso() . "')"); $this->_jobs = $entry_query->objects(); $num_jobs = sizeof($this->_jobs); if ($num_jobs) { $props = $renderer->make_list_properties(); $props->height = min($num_jobs + 1, 10); $props->add_item('[None]', 0); /** @var $j JOB */ foreach ($this->_jobs as $j) { $t = $j->title_formatter(); $t->max_visible_output_chars = 55; $props->add_item($j->title_as_plain_text($t), $j->id); } $job = $this->job_at($this->value_for('job_id')); $job_text = 'A change can be attached to the job to which it contributed. Only the jobs for the selected branch and release are shown.'; if ($job) { $renderer->draw_text_row(' ', $job_text . ' The current job is previewed above.', 'notes'); $renderer->draw_list_box_row('job_id', $props); } else { $renderer->draw_text_row(' ', $job_text, 'notes'); $renderer->draw_list_box_row('job_id', $props); } } $renderer->draw_submit_button_row(); $this->_draw_history_item_controls($renderer); $renderer->finish(); }
/** * Record difference in times, if any * @param string $name * @param DATE_TIME $orig_date * @param DATE_TIME $new_date * @param string $type Type of date-time formatting to use. * @access private */ protected function _record_time_difference($name, $orig_date, $new_date, $type = Date_time_format_short_date_and_time) { if (!$orig_date->equals($new_date)) { $f = $orig_date->formatter(); $f->set_type_and_clear_flags($type); if ($orig_date->is_valid()) { $orig_text = $orig_date->format($f); } else { $orig_text = '[not set]'; } if ($new_date->is_valid()) { $new_text = $new_date->format($f); } else { $new_text = '[not set]'; } $this->_record_string_difference($name, $orig_text, $new_text); } }
/** * @param DATE_TIME $t1 * @param DATE_TIME $t2 */ public function __construct($t1, $t2) { $php_t1 = $t1->as_php(); $php_t2 = $t2->as_php(); $this->_total_seconds = $php_t1 - $php_t2; }
/** * Restrict the query to the time frame. * @param QUERY $query */ public function prepare_query($query) { if (!$query) { $this->raise("'query' cannot be empty", 'prepare_query', 'TIME_FRAME_SELECTOR'); } switch ($this->period) { case Time_frame_recent: $query->set_limits(0, $this->num_in_recent); break; case Time_frame_today: $first = new DATE_TIME(mktime(0, 0, 0, date('n'), date('d'), date('Y'))); $last = new DATE_TIME(time()); $query->set_days($first->as_iso(), $last->as_iso()); break; case Time_frame_last_week: $now = time(); $last = new DATE_TIME($now); $first = new DATE_TIME($now - 86400 * 7); $query->set_days($first->as_iso(), $last->as_iso()); break; case Time_frame_last_month: $now = time(); $last = new DATE_TIME($now); $first = new DATE_TIME($now - 86400 * 30); $query->set_days($first->as_iso(), $last->as_iso()); break; case Time_frame_all: break; } if ($this->period != Time_frame_all) { $query->order_by_recent(); } }
/** * Restrict on a date field. * 'from' or 'to' may be empty. * @param string $field * @param DATE_TIME $from * @param DATE_TIME $to */ public function restrict_date($field, $from, $to) { if ($from && $from->is_valid()) { $this->restrict("{$field} >= '" . $from->as_ISO() . "'"); } if ($to && $to->is_valid()) { $this->restrict("{$field} <= '" . $to->as_ISO() . "'"); } }
/** * @var FORM $form */ public function validate($form) { parent::validate($form); if ($this->continue_validating($form)) { /** @var $value DATE_TIME */ $value = $this->_value; if (!$value->is_valid()) { $form->record_error($this->id, "[{$this->_text_value}] is not a valid date/time. Use [d.m.Y] or [m/d/Y] or [Y-m-d]"); } else { $date = $value; if (isset($this->max_date)) { if (isset($this->min_date)) { if ($date->less_than_equal($this->min_date) || $this->max_date->less_than_equal($date)) { $form->record_error($this->id, 'Please enter a date between ' . $this->min_date->as_iso() . ' and ' . $this->max_date->as_iso() . " for {$this->caption}"); } } else { if ($this->max_date->less_than_equal($date)) { $form->record_error($this->id, 'Please enter a date less than ' . $this->max_date->as_iso() . " for {$this->caption}"); } } } else { if (isset($this->min_date)) { if ($date->less_than_equal($this->min_date)) { $form->record_error($this->id, 'Please enter a date greater than ' . $this->min_date->as_iso() . " for {$this->caption}"); } } } } } }
/** * Format a date for display. * @param DATE_TIME $date * @param boolean $text_only Do not use tags when formatting. * @return string * @access private */ protected function _date($date, $text_only) { $Result = ''; if (isset($date) && $date->is_valid()) { $f = $date->formatter(); $f->type = Date_time_format_short_date; $f->show_local_time = !$text_only && $this->context->local_times_allowed(); $f->show_CSS = !$text_only; $Result = $date->format($f); if (!$text_only) { $Result = '<span class="visible">' . $Result . '</span>'; } } return $Result; }
/** * Called when the page is set before rendering. * * This calendar caches the pictures and journals for the new page. * * @access private */ protected function _page_changed() { $first_day = new DATE_TIME(mktime(0, 0, 0, $this->_curr_month, 1, $this->_curr_year)); $last_day = new DATE_TIME(mktime(23, 59, 59, $this->_curr_month, $first_day->last_legal_day(), $this->_curr_year)); $journal_query = $this->album->entry_query(); $journal_query->set_type('journal'); $journal_query->set_days($first_day->as_iso(), $last_day->as_iso()); $this->_journals = $journal_query->objects(); $picture_query = $this->album->entry_query(); $picture_query->set_type('picture'); $picture_query->set_days($first_day->as_iso(), $last_day->as_iso()); $this->_pictures = $picture_query->objects(); }
/** * A date which uses this application's formatter. * @param integer $time Can be either a timestamp or an ISO-formatted time * @param string $type Can be either Date_time_php or Date_time_iso * @return DATE_TIME */ public function make_date_time($time = 0, $type = null) { $Result = new DATE_TIME($time, $type); $this->date_time_toolkit->formatter->show_local_time = $this->local_times_allowed(); $Result->use_toolkit($this->date_time_toolkit); return $Result; }
/** * Does this form hold valid data for this album? * @param ALBUM $obj * @access private */ protected function _post_validate($obj) { parent::_post_validate($obj); /** @var DATE_TIME $first_day_value */ $first_day_value = $this->value_for('first_day'); /** @var DATE_TIME $last_day_value */ $last_day_value = $this->value_for('last_day'); switch ($this->value_for('date_style')) { case Album_is_journal: $now = new DATE_TIME(); if ($now->less_than($first_day_value)) { $this->record_error('first_day', 'First day of a journal cannot be in the future.'); } break; case Album_is_span: if ($last_day_value->less_than($first_day_value)) { $this->record_error('last_day', 'First day must come before the last day.'); } break; } if ($this->value_for('constrain_picture_size') && ($this->value_for('max_picture_width') == 0 || $this->value_for('max_picture_width') == 0)) { $this->record_error('picture', 'Please make sure that both picture width and height are greater than 0.'); } }
protected function _finish_body() { $page = $this->page; $options = $page->template_options; $browser = $this->env->browser(); if ($options->close_logger) { $this->env->logs->close_all(); } ?> </div> <?php if ($options->footer_visible && !$browser->is(Browser_previewer)) { ?> <div class="footer"> <?php /* Build the left side of the footer with the copyright and version info. */ $lines = array(); if ($options->show_links) { $lines[] = '<div class="footer-links">' . $this->_links_as_text($options) . '</div>'; } if ($options->copyright) { $lines[] = '<div class="copyright">' . $options->copyright . '</div>'; } if ($options->show_versions) { $lines[] = '<div class="versions">' . $this->_versions_as_text($options) . '</div>'; } if ($options->show_last_time_modified) { $date = new DATE_TIME(getlastmod()); $f = $date->formatter(); $f->set_type_and_clear_flags(Date_time_format_short_date_and_time); $lines[] = '<div class="modification-time">Last modified on ' . $date->format($f) . '</div>'; } if ($options->show_statistics) { $lines[] = '<div class="statistics">' . $this->_page_statistics_as_text($options) . '</div>'; } echo '<div class="footer-data">'; echo join('</div><div class="footer-data">', $lines); echo '</div>'; $this->_handle_browser_warnings($options, false); ?> </div> <?php } ?> </div> <?php parent::_finish_body(); }
/** * @param DATABASE $db Database from which to load values. */ public function load($db) { parent::load($db); $this->title = $db->f('title'); $this->renderer_class_name = $db->f('renderer_class_name'); $this->main_CSS_file_name = $db->f('main_CSS_file_name'); $this->font_name_CSS_file_name = $db->f('font_name_CSS_file_name'); $this->font_size_CSS_file_name = $db->f('font_size_CSS_file_name'); $this->icon_set = $db->f('icon_set'); $this->icon_extension = $db->f('icon_extension'); $this->time_created->set_from_iso($db->f('time_created')); }