Beispiel #1
0
 /**
  * display the content of one instance
  *
  * @see overlays/overlay.php
  *
  * @param array the hosting record
  * @return some HTML to be inserted into the resulting page
  */
 function &get_view_text($host = NULL)
 {
     global $context;
     // we may look at enrolments
     include_once $context['path_to_root'] . 'shared/enrolments.php';
     // minutes to go
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp'] > NULL_DATE) {
         $this->minutes_before_start = (sql::strtotime($this->attributes['date_stamp']) - time()) / 60;
     } else {
         $this->minutes_before_start = 120;
     }
     // prevent automatic start
     // minutes since the end of the event
     if (isset($this->attributes['duration']) && $this->attributes['duration']) {
         $this->minutes_since_stop = -($this->attributes['duration'] + $this->minutes_before_start);
     } else {
         $this->minutes_since_stop = -120;
     }
     // prevent automatic stop
     // tabular information
     $rows = array();
     // initialize feed-back to end-user
     $this->feed_back = array('message' => '', 'status' => array(), 'menu' => array(), 'commands' => array(), 'reload_this_page' => FALSE);
     // maybe a bare instance
     if (!isset($this->attributes['status'])) {
         $this->attributes['status'] = 'created';
     }
     // step 5 - end of the event
     if ($this->attributes['status'] == 'stopped') {
         // list enrolment for this meeting
         $query = "SELECT * FROM " . SQL::table_name('enrolments') . " WHERE anchor LIKE '" . SQL::escape($this->anchor->get_reference()) . "'";
         if ($result = SQL::query($query)) {
             // browse the list
             $items = array();
             while ($item = SQL::fetch($result)) {
                 // a user registered on this server
                 if ($item['user_id'] && ($user = Users::get($item['user_id']))) {
                     // make an url
                     $url = Users::get_permalink($user);
                     // gather information on this user
                     if (isset($user['full_name']) && $user['full_name']) {
                         $label = $user['full_name'] . ' (' . $user['nick_name'] . ')';
                     } else {
                         $label = $user['nick_name'];
                     }
                     $items[] = Skin::build_link($url, $label, 'user');
                     // we only have some e-mail address
                 } else {
                     $items[] = $item['user_email'];
                 }
             }
             // shape a compact list
             if (count($items)) {
                 $this->feed_back['status'][] = Skin::build_folded_box(i18n::s('Enrolment') . ' (' . count($items) . ')', Skin::finalize_list($items, 'compact'));
             }
         }
         // signal that the event is over
         $this->feed_back['status'][] = i18n::s('Event is over');
         // display the follow-up message
         if (isset($this->attributes['follow_up_message']) && $this->attributes['follow_up_message']) {
             $this->feed_back['message'] .= Codes::render($this->attributes['follow_up_message']);
         }
         // possible transition to state 'stopped'
     } else {
         $this->transition_to_stopped();
     }
     // step 4 - event has started
     if ($this->attributes['status'] == 'started') {
         // display the welcome message
         if (isset($this->attributes['welcome_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['welcome_message']);
         }
         // possible transition to state 'started'
     } else {
         $this->transition_to_started();
     }
     // step 3 - waiting for event start
     if ($this->attributes['status'] == 'lobby') {
         // display the lobby message
         if (isset($this->attributes['lobby_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['lobby_message']);
         }
         // possible transition to state 'lobby'
     } else {
         $this->transition_to_lobby();
     }
     // step 2 - enrolment has been opened
     if ($this->attributes['status'] == 'open') {
         // display the induction message
         if (isset($this->attributes['induction_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['induction_message']);
         }
         // possible transition to state 'open'
     } else {
         $this->transition_to_open();
     }
     // step 1 - at the very beginning of the workflow
     if (!isset($this->attributes['status']) || $this->attributes['status'] == 'created') {
         // display the induction message
         if (isset($this->attributes['induction_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['induction_message']);
         }
         // possible transition to state 'created'
     } else {
         $this->transition_to_created();
     }
     // event details
     if ($details = $this->get_event_details_text()) {
         $rows[] = array($this->get_event_details_label(), $details);
     }
     // meeting date
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         // offer to update the calendar
         $button = '';
         if ($this->attributes['status'] == 'stopped') {
         } elseif (enrolments::get_record($this->anchor->get_reference())) {
             $button = ' ' . Skin::build_link($this->get_url('fetch_ics'), '<img src="' . $context['url_to_root'] . 'included/jscalendar/img.gif" style="border: none; cursor: pointer;" title="' . i18n::s('Update my calendar') . '" onmouseover="this.style.background=\'red\';" onmouseout="this.style.background=\'\'" alt="' . i18n::s('Update my calendar') . '" />', 'basic');
         }
         $rows[] = array(i18n::s('Date'), Skin::build_date($this->attributes['date_stamp'], 'full') . $button);
     }
     // meeting duration
     if (isset($this->attributes['duration']) && $this->attributes['duration'] && $this->attributes['duration'] < 1440) {
         switch ($this->attributes['duration']) {
             case 60:
                 $duration = i18n::s('one hour');
                 break;
             case 120:
                 $duration = i18n::s('two hours');
                 break;
             default:
                 $duration = sprintf(i18n::s('%d minutes'), $this->attributes['duration']);
                 break;
         }
         $rows[] = array(i18n::s('Duration'), $duration);
     }
     // build a link to the owner page, if any
     if (isset($this->attributes['chairman']) && $this->attributes['chairman']) {
         if ($user = Users::get($this->attributes['chairman'])) {
             $label = Users::get_link($user['full_name'], NULL, $user['id']);
         } else {
             $label = $this->attributes['chairman'];
         }
         $rows[] = array(i18n::s('Chairman'), $label);
     }
     // finalize status
     if (is_callable(array($this, 'finalize_status'))) {
         $this->feed_back['status'] = $this->finalize_status($this->feed_back['status']);
     }
     // finalize menu
     if (is_callable(array($this, 'finalize_menu'))) {
         $this->feed_back['menu'] = $this->finalize_menu($this->feed_back['menu']);
     }
     // we have to refresh the page
     if ($this->feed_back['reload_this_page']) {
         $reload_through_javascript = '<img alt="*" src="' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/ajax/ajax_spinner.gif" style="vertical-align:-3px" /> ';
         Page::insert_script('window.location.reload(true);');
         $rows[] = array(i18n::s('Status'), $reload_through_javascript);
         // display the status line and/or buttons
     } elseif (count($this->feed_back['status']) || count($this->feed_back['menu'])) {
         $status = '';
         // embed status line
         if (count($this->feed_back['status'])) {
             $status .= implode(BR, $this->feed_back['status']);
         }
         // embed menu bar
         if (count($this->feed_back['menu'])) {
             $status .= Skin::finalize_list($this->feed_back['menu'], 'menu_bar');
         }
         $rows[] = array(i18n::s('Status'), $status);
     }
     // display commands to page owner
     if (count($this->feed_back['commands'])) {
         $rows[] = array('', Skin::finalize_list($this->feed_back['commands'], 'menu_bar'));
     }
     // format text in a table
     $text = Skin::table(NULL, $rows, 'grid');
     // finalize feed-back
     if ($this->feed_back['message']) {
         $text .= Skin::build_box($this->get_message_label(), $this->feed_back['message']);
     }
     // allow for extensions
     if (is_callable(array($this, 'get_view_text_extension'))) {
         $text .= $this->get_view_text_extension();
     }
     // job done
     return $text;
 }
Beispiel #2
0
Datei: day.php Projekt: rair/yacs
 /**
  * get invitation default message
  *
  * This is put in the invitation form.
  *
  * @see articles/invite.php
  *
  * @param string 'PUBLISH' or 'CANCEL'
  * @return string to be put in the web form
  */
 function get_invite_default_message($method = 'PUBLISH')
 {
     global $context;
     // to be displayed into the web form for this invitation
     $text = '';
     if ($value = $this->anchor->get_title()) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Topic'), Skin::build_link($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url(), Codes::beautify_title($value))) . BR;
     }
     // dates
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Date'), Skin::build_date($this->attributes['date_stamp'], 'day')) . BR;
     }
     // build a link to the chairman page, if any
     if (isset($this->attributes['chairman']) && ($user = Users::get($this->attributes['chairman']))) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Chairman'), Users::get_link($user['full_name'], NULL, $user['id'])) . BR;
     }
     // event has been cancelled
     if ($method == 'CANCEL') {
         $text .= '<div><p>' . i18n::c('Event has been cancelled.') . '</p></div>';
     } else {
         // copy content of the introduction field, if any
         if ($value = $this->anchor->get_value('introduction')) {
             $text .= '<div>' . Codes::beautify('<p>' . $value . '</p>') . '</div>';
         }
         // copy the induction message, if any
         if (isset($this->attributes['induction_message'])) {
             $text .= '<div>' . Codes::render($this->attributes['induction_message']) . '</div>';
         }
     }
     // done
     return $text;
 }
Beispiel #3
0
 /**
  * format an introduction
  *
  * @param string raw introduction
  * @return string finalized title
  */
 public static function beautify_introduction($text)
 {
     // render codes
     $output = Codes::render($text);
     // render smileys after codes, else it will break escaped strings
     if (is_callable(array('Smileys', 'render_smileys'))) {
         $output = Smileys::render_smileys($output);
     }
     // return by reference
     return $output;
 }