コード例 #1
0
 public function main()
 {
     $asset_path = $this->sitemaker->asset_path;
     $this->sitemaker->add_assets(array('js' => array('//ajax.googleapis.com/ajax/libs/jqueryui/' . JQUI_VERSION . '/jquery-ui.min.js', $asset_path . 'ext/blitze/sitemaker/components/jquery-knob/js/jquery.knob.min.js', $asset_path . 'ext/blitze/sitemaker/components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.js', $asset_path . 'ext/blitze/sitemaker/components/moment/moment.min.js', $asset_path . 'ext/blitze/sitemaker/components/jquery-rss/dist/jquery.rss.min.js', $asset_path . 'ext/blitze/sitemaker/components/jquery.sparkline/index.min.js', '@blitze_sitemaker/assets/adm/dashboard.min.js'), 'css' => array('//ajax.googleapis.com/ajax/libs/jqueryui/' . JQUI_VERSION . '/themes/smoothness/jquery-ui.css', $asset_path . 'ext/blitze/sitemaker/components/fontawesome/css/font-awesome.min.css', $asset_path . 'ext/blitze/sitemaker/components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css', '@blitze_sitemaker/assets/adm/dashboard.min.css')));
     $time = $this->user->create_datetime();
     $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
     $wday = $now['wday'];
     $weekdays = array();
     while ($wday >= 0) {
         $weekdays[$wday] = 0;
         $wday--;
     }
     for ($i = 6, $size = sizeof($weekdays); $i >= $size; $i--) {
         $weekdays[$i] = 0;
     }
     $weekdays = array_reverse($weekdays, true);
     $count = 0;
     $js_weekdays = array();
     for ($i = 6; $i >= 0; $i--) {
         $js_weekdays[] = "{$count}: '" . $this->user->format_date(strtotime("- {$i} days"), 'l M j', true) . "'";
         $count++;
     }
     $this->template->assign_var('UA_WEEKDAYS', join(', ', $js_weekdays));
     $lookback = $now[0] - 6 * 24 * 3600;
     $boarddays = ($now[0] - $this->config['board_startdate']) / 86400;
     $this->get_stats('users', $weekdays, $lookback, $boarddays);
     $this->get_stats('topics', $weekdays, $lookback, $boarddays);
     $this->get_stats('posts', $weekdays, $lookback, $boarddays);
     $this->get_stats('files', $weekdays, $lookback, $boarddays);
     $this->user_contributions();
     // Set up the page
     $this->tpl_name = 'acp_dashboard';
     $this->page_title = 'SITEMAKER_DASHBOARD';
 }
コード例 #2
0
 protected function get_year(array $now)
 {
     $start = $this->user->create_datetime()->setDate($now['year'], 1, 1)->setTime(0, 0, 0)->getTimestamp();
     $leap_year = gmdate('L', $start);
     $num_days = $leap_year ? 366 : 365;
     return array('start' => $start, 'stop' => $start + 86400 * $num_days - 1, 'date' => $this->user->format_date($start, 'Y', true));
 }
コード例 #3
0
 /**
  * Generate ISO 8601 date string (RFC 3339)
  */
 public function format_date($time)
 {
     static $zone_offset;
     static $offset_string;
     if (empty($offset_string)) {
         $zone_offset = $this->user->create_datetime()->getOffset();
         $offset_string = phpbb_format_timezone_offset($zone_offset);
     }
     return gmdate("Y-m-d\\TH:i:s", $time + $zone_offset) . $offset_string;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function get_template_side($module_id)
 {
     // Generate birthday list if required ... / borrowed from index.php 3.0.6
     $birthday_list = $birthday_ahead_list = '';
     if ($this->config['load_birthdays'] && $this->config['allow_birthdays']) {
         $time = $this->user->create_datetime();
         $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
         $cache_days = $this->config['board3_birthdays_ahead_' . $module_id];
         $sql_days = '';
         while ($cache_days > 0) {
             $day = phpbb_gmgetdate($time->getTimestamp() + 86400 * $cache_days + $time->getOffset());
             $like_expression = $this->db->sql_like_expression($this->db->get_any_char() . sprintf('%2d-%2d-', $day['mday'], $day['mon']) . $this->db->get_any_char());
             $sql_days .= " OR u.user_birthday " . $like_expression . "";
             $cache_days--;
         }
         switch ($this->db->get_sql_layer()) {
             case 'mssql':
             case 'mssql_odbc':
                 $order_by = 'u.user_birthday ASC';
                 break;
             default:
                 $order_by = 'SUBSTRING(u.user_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.user_birthday FROM 1 FOR 2) ASC, u.username_clean ASC';
                 break;
         }
         $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_colour, u.user_birthday', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(BANLIST_TABLE => 'b'), 'ON' => 'u.user_id = b.ban_userid')), 'WHERE' => "(b.ban_id IS NULL\n\t\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday " . $this->db->sql_like_expression($this->db->get_any_char() . sprintf('%2d-%2d-', $now['mday'], $now['mon']) . $this->db->get_any_char()) . " {$sql_days})\n\t\t\t\t\tAND " . $this->db->sql_in_set('u.user_type', array(USER_NORMAL, USER_FOUNDER)), 'ORDER BY' => $order_by);
         $sql = $this->db->sql_build_query('SELECT', $sql_array);
         $result = $this->db->sql_query($sql, 3600);
         $today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);
         while ($row = $this->db->sql_fetchrow($result)) {
             if (substr($row['user_birthday'], 0, 6) == $today) {
                 $birthday_list = true;
                 $this->template->assign_block_vars('board3_birthday_list', array('USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : ''));
             } else {
                 if ($this->config['board3_birthdays_ahead_' . $module_id] > 0) {
                     $birthday_ahead_list = true;
                     $this->template->assign_block_vars('board3_birthday_ahead_list', array('USER' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'AGE' => ($age = (int) substr($row['user_birthday'], -4)) ? ' (' . ($now['year'] - $age) . ')' : '', 'DATE' => $this->format_birthday($this->user, $row['user_birthday'], 'd M')));
                 }
             }
         }
         $this->db->sql_freeresult($result);
     }
     // Assign index specific vars
     $this->template->assign_vars(array('BIRTHDAY_LIST' => $birthday_list, 'BIRTHDAYS_AHEAD_LIST' => $this->config['board3_birthdays_ahead_' . $module_id] ? $birthday_ahead_list : '', 'L_BIRTHDAYS_AHEAD' => sprintf($this->user->lang['BIRTHDAYS_AHEAD'], $this->config['board3_birthdays_ahead_' . $module_id]), 'S_DISPLAY_BIRTHDAY_LIST' => $this->config['load_birthdays'] ? true : false, 'S_DISPLAY_BIRTHDAY_AHEAD_LIST' => $this->config['board3_birthdays_ahead_' . $module_id] > 0 ? true : false));
     return 'birthdays_side.html';
 }
コード例 #5
0
    /**
     * @return bool
     */
    private function _find_birthday_users()
    {
        $time = $this->user->create_datetime($this->time);
        $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
        $leap_year_birthdays = $this->_adjust_leap_year($now, $time);
        $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday 
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (u.user_birthday LIKE '" . $this->db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$leap_year_birthdays})\n\t\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
				ORDER BY u.username ASC';
        $result = $this->db->sql_query($sql);
        $show_birthday = false;
        while ($row = $this->db->sql_fetchrow($result)) {
            $show_birthday = true;
            $this->ptemplate->assign_block_vars('birthday', array('USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'USER_AGE' => $this->_get_user_age($row['user_birthday'], $now['year'])));
        }
        $this->db->sql_freeresult($result);
        return $show_birthday;
    }
コード例 #6
0
ファイル: type_date.php プロジェクト: Tarendai/spring-website
 /**
  * {@inheritDoc}
  */
 public function get_profile_value($field_value, $field_data)
 {
     $date = explode('-', $field_value);
     $day = isset($date[0]) ? (int) $date[0] : 0;
     $month = isset($date[1]) ? (int) $date[1] : 0;
     $year = isset($date[2]) ? (int) $date[2] : 0;
     if (!$day && !$month && !$year && !$field_data['field_show_novalue']) {
         return null;
     } else {
         if ($day && $month && $year) {
             // Date should display as the same date for every user regardless of timezone
             return $this->user->create_datetime()->setDate($year, $month, $day)->setTime(0, 0, 0)->format($this->user->lang['DATE_FORMAT'], true);
         }
     }
     return $field_value;
 }
コード例 #7
0
    public function upcoming_birthdays()
    {
        $time = $this->user->create_datetime();
        $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
        $today = mktime(0, 0, 0, $now['mon'], $now['mday'], $now['year']);
        // Number of seconds per day
        $secs_per_day = 24 * 60 * 60;
        // We will use the timezone offset for our cache name
        $cache_name = $time->getOffset();
        $cache_name = str_replace('-', 'minus_', $cache_name);
        $cache_name = $cache_name . '_ubl';
        if (($upcomingbirthdays = $this->cache->get('_' . $cache_name)) === false) {
            // Only care about dates ahead of today.  Start date is always tomorrow
            $date_start = $now[0] + $secs_per_day;
            $date_end = $date_start + (int) $this->config['allow_birthdays_ahead'] * $secs_per_day;
            $dates = array();
            while ($date_start <= $date_end) {
                $day = date('j', $date_start);
                $month = date('n', $date_start);
                $dates[] = $this->db->sql_escape(sprintf('%2d-%2d-', $day, $month));
                $date_start = $date_start + $secs_per_day;
            }
            $sql_array = array();
            foreach ($dates as $date) {
                $sql_array[] = "u.user_birthday LIKE '" . $date . "%'";
            }
            $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday, b.ban_id
				FROM ' . USERS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)\n\t\t\t\tWHERE (b.ban_id IS NULL\n\t\t\t\t\tOR b.ban_exclude = 1)\n\t\t\t\t\tAND (" . implode(' OR ', $sql_array) . ")\n\t\t\t\t\tAND " . $this->db->sql_in_set('u.user_type', array(USER_NORMAL, USER_FOUNDER));
            $result = $this->db->sql_query($sql);
            $upcomingbirthdays = array();
            while ($row = $this->db->sql_fetchrow($result)) {
                $bdday = $bdmonth = 0;
                list($bdday, $bdmonth) = array_map('intval', explode('-', $row['user_birthday']));
                $bdcheck = strtotime(gmdate('Y') . '-' . (int) trim($bdmonth) . '-' . (int) trim($bdday) . ' UTC');
                $bdyear = $bdcheck < $today ? (int) gmdate('Y') + 1 : (int) gmdate('Y');
                $bddate = $bdyear . '-' . (int) $bdmonth . '-' . (int) $bdday;
                // re-write those who have feb 29th as a birthday but only on non leap years
                if ((int) trim($bdday) == 29 && (int) trim($bdmonth) == 2) {
                    if (!$this->is_leap_year($bdyear) && !$time->format('L')) {
                        $bdday = 28;
                        $bddate = $bdyear . '-' . (int) trim($bdmonth) . '-' . (int) trim($bdday);
                    }
                }
                $upcomingbirthdays[] = array('user_birthday_tstamp' => strtotime($bddate . ' UTC'), 'username' => $row['username'], 'user_birthdayyear' => $bdyear, 'user_birthday' => $row['user_birthday'], 'user_id' => $row['user_id'], 'user_colour' => $row['user_colour']);
            }
            $this->db->sql_freeresult($result);
            // cache this data for one hour, this improves performance
            $this->cache->put('_' . $cache_name, $upcomingbirthdays, 3600);
        }
        sort($upcomingbirthdays);
        $birthday_ahead_list = '';
        $tomorrow = mktime(0, 0, 0, $now['mon'], $now['mday'] + 1, $now['year']);
        for ($i = 0, $end = sizeof($upcomingbirthdays); $i < $end; $i++) {
            if ($upcomingbirthdays[$i]['user_birthday_tstamp'] >= $tomorrow && $upcomingbirthdays[$i]['user_birthday_tstamp'] <= $today + $this->config['allow_birthdays_ahead'] * $secs_per_day) {
                $user_link = get_username_string('full', $upcomingbirthdays[$i]['user_id'], $upcomingbirthdays[$i]['username'], $upcomingbirthdays[$i]['user_colour']);
                $birthdate = getdate($upcomingbirthdays[$i]['user_birthday_tstamp']);
                //lets add to the birthday_ahead list.
                $birthday_ahead_list .= ($birthday_ahead_list != '' ? $this->user->lang['COMMA_SEPARATOR'] : '') . '<span title="' . $birthdate['mday'] . '-' . $birthdate['mon'] . '-' . $birthdate['year'] . '">' . $user_link . '</span>';
                if ($age = (int) substr($upcomingbirthdays[$i]['user_birthday'], -4)) {
                    $birthday_ahead_list .= ' (' . ($upcomingbirthdays[$i]['user_birthdayyear'] - $age) . ')';
                }
            }
        }
        // Assign index specific vars
        $this->template->assign_vars(array('BIRTHDAYS_AHEAD_LIST' => $birthday_ahead_list, 'L_BIRTHDAYS_AHEAD' => $this->user->lang('BIRTHDAYS_AHEAD', $this->config['allow_birthdays_ahead'])));
    }
コード例 #8
0
/**
* Options to pick a timezone and date/time
*
* @param	\phpbb\template\template $template	phpBB template object
* @param	\phpbb\user	$user				Object of the current user
* @param	string		$default			A timezone to select
* @param	boolean		$truncate			Shall we truncate the options text
*
* @return		array		Returns an array containing the options for the time selector.
*/
function phpbb_timezone_select($template, $user, $default = '', $truncate = false)
{
    static $timezones;
    $default_offset = '';
    if (!isset($timezones)) {
        $unsorted_timezones = phpbb_get_timezone_identifiers($default);
        $timezones = array();
        foreach ($unsorted_timezones as $timezone) {
            $tz = new DateTimeZone($timezone);
            $dt = $user->create_datetime('now', $tz);
            $offset = $dt->getOffset();
            $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true);
            $offset_string = phpbb_format_timezone_offset($offset, true);
            $timezones['UTC' . $offset_string . ' - ' . $timezone] = array('tz' => $timezone, 'offset' => $offset_string, 'current' => $current_time);
            if ($timezone === $default) {
                $default_offset = 'UTC' . $offset_string;
            }
        }
        unset($unsorted_timezones);
        uksort($timezones, 'phpbb_tz_select_compare');
    }
    $tz_select = $opt_group = '';
    foreach ($timezones as $key => $timezone) {
        if ($opt_group != $timezone['offset']) {
            // Generate tz_select for backwards compatibility
            $tz_select .= $opt_group ? '</optgroup>' : '';
            $tz_select .= '<optgroup label="' . $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']) . '">';
            $opt_group = $timezone['offset'];
            $template->assign_block_vars('timezone_select', array('LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']), 'VALUE' => $key . ' - ' . $timezone['current']));
            $selected = !empty($default_offset) && strpos($key, $default_offset) !== false ? ' selected="selected"' : '';
            $template->assign_block_vars('timezone_date', array('VALUE' => $key . ' - ' . $timezone['current'], 'SELECTED' => !empty($selected), 'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current'])));
        }
        $label = $timezone['tz'];
        if (isset($user->lang['timezones'][$label])) {
            $label = $user->lang['timezones'][$label];
        }
        $title = $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $label);
        if ($truncate) {
            $label = truncate_string($label, 50, 255, false, '...');
        }
        // Also generate timezone_select for backwards compatibility
        $selected = $timezone['tz'] === $default ? ' selected="selected"' : '';
        $tz_select .= '<option title="' . $title . '" value="' . $timezone['tz'] . '"' . $selected . '>' . $label . '</option>';
        $template->assign_block_vars('timezone_select.timezone_options', array('TITLE' => $title, 'VALUE' => $timezone['tz'], 'SELECTED' => !empty($selected), 'LABEL' => $label));
    }
    $tz_select .= '</optgroup>';
    return $tz_select;
}
コード例 #9
0
ファイル: calendar.php プロジェクト: alhitary/Board3-Portal
 /**
  * Get date listed in array
  *
  * @param string $call_date Date
  *
  * @return null
  */
 protected function get_month($call_date)
 {
     $this->make_timestamp($call_date);
     // last or first day of some months need to be treated in a special way
     if (!empty($this->mini_cal_month)) {
         $time = $this->user->create_datetime();
         $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
         $today_timestamp = $now[0];
         $cur_month = date("n", $today_timestamp);
         $correct_month = $cur_month + $this->mini_cal_month;
         // move back or forth the correct number of years
         while ($correct_month < 1 || $correct_month > self::MONTHS_PER_YEAR) {
             $correct_month = $correct_month < 1 ? $correct_month + self::MONTHS_PER_YEAR : $correct_month - self::MONTHS_PER_YEAR;
         }
         // fix incorrect months
         while (date("n", $this->stamp) != $correct_month) {
             // Go back one day or move forward in order to
             // get to the correct month
             $this->stamp = date("n", $this->stamp) > $correct_month ? $this->stamp - self::TIME_DAY : $this->stamp + self::TIME_DAY;
         }
     }
     $this->dateYYYY = (int) date("Y", $this->stamp);
     $this->dateMM = (int) date("n", $this->stamp);
     $this->ext_dateMM = date("F", $this->stamp);
     $this->dateDD = (int) date("d", $this->stamp);
     $this->daysMonth = (int) date("t", $this->stamp);
     for ($i = 1; $i < $this->daysMonth + 1; $i++) {
         $this->make_timestamp("{$i} {$this->ext_dateMM} {$this->dateYYYY}");
         $this->day[] = array('0' => "{$i}", '1' => $this->dateMM, '2' => $this->dateYYYY, '3' => date('w', $this->stamp));
     }
 }