private function build_table()
    {
        $table_model = new SQLHTMLTableModel(CalendarSetup::$calendar_events_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('date', 'date-common'), 'start_date'), new HTMLTableColumn($this->lang['calendar.titles.repetition']), new HTMLTableColumn(LangLoader::get_message('status.approved', 'common'), 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('start_date', HTMLTableSortingRule::DESC));
        $table = new HTMLTable($table_model);
        $table_model->set_caption($this->lang['calendar.config.events.management']);
        $table_model->add_permanent_filter('parent_id = 0');
        $results = array();
        $result = $table_model->get_sql_results('event
			LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id');
        foreach ($result as $row) {
            $event = new CalendarEvent();
            $event->set_properties($row);
            $category = $event->get_content()->get_category();
            $user = $event->get_content()->get_author_user();
            $edit_link = new LinkHTMLElement(CalendarUrlBuilder::edit_event(!$event->get_parent_id() ? $event->get_id() : $event->get_parent_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
            $delete_link = new LinkHTMLElement(CalendarUrlBuilder::delete_event($event->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => !$event->belongs_to_a_serie() ? 'delete-element' : ''), 'fa fa-delete');
            $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
            $author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
            $br = new BrHTMLElement();
            $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()), $event->get_content()->get_title()), 'left'), new HTMLTableRowCell(new SpanHTMLElement($category->get_name(), array('style' => $category->get_id() != Category::ROOT_CATEGORY && $category->get_color() ? 'color:' . $category->get_color() : ''))), new HTMLTableRowCell($author), new HTMLTableRowCell(LangLoader::get_message('from_date', 'main') . ' ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('to_date', 'main') . ' ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($event->belongs_to_a_serie() ? $this->lang['calendar.labels.repeat.' . $event->get_content()->get_repeat_type()] . ' - ' . $event->get_content()->get_repeat_number() . ' ' . $this->lang['calendar.labels.repeat_times'] : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($event->get_content()->is_approved() ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
        }
        $table->set_rows($table_model->get_number_of_matching_rows(), $results);
        $this->view->put('table', $table->display());
    }
 public function __construct($view, $title_page)
 {
     parent::__construct($view);
     $lang = LangLoader::get('common', 'calendar');
     $this->set_title($lang['module_title']);
     $this->add_link(LangLoader::get_message('categories.management', 'categories-common'), CalendarUrlBuilder::manage_categories());
     $this->add_link(LangLoader::get_message('category.add', 'categories-common'), CalendarUrlBuilder::add_category());
     $this->add_link($lang['calendar.config.events.management'], CalendarUrlBuilder::manage_events());
     $this->add_link($lang['calendar.titles.add_event'], CalendarUrlBuilder::add_event());
     $this->add_link(LangLoader::get_message('configuration', 'admin-common'), CalendarUrlBuilder::configuration());
     $env = $this->get_graphical_environment();
     $env->set_page_title($title_page, $lang['module_title']);
 }
    public function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (CalendarService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $now = new Date();
            $lang = LangLoader::get('common', 'calendar');
            $querier = PersistenceContext::get_querier();
            $category = CalendarService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = $lang['calendar.feed.name'];
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('calendar', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = CalendarService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $result = $querier->select('SELECT *
			FROM ' . CalendarSetup::$calendar_events_table . ' event
			LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id
			LEFT JOIN ' . CalendarSetup::$calendar_cats_table . ' cat ON cat.id = event_content.id_category
			WHERE approved = 1
			AND id_category IN :cats_ids
			ORDER BY start_date DESC', array('cats_ids' => $ids_categories));
            while ($row = $result->fetch()) {
                $event = new CalendarEvent();
                $event->set_properties($row);
                $category = $categories[$event->get_content()->get_category_id()];
                $link = CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name() ? $category->get_rewrited_name() : 'root', $event->get_id(), $event->get_content()->get_rewrited_title());
                $item = new FeedItem();
                $item->set_title($event->get_content()->get_title());
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($event->get_content()->get_contents()) . ($event->get_content()->get_location() ? '<br />' . $lang['calendar.labels.location'] . ' : ' . $event->get_content()->get_location() . '<br />' : '') . '<br />' . $lang['calendar.labels.start_date'] . ' : ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br />' . $lang['calendar.labels.end_date'] . ' : ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE));
                $item->set_date($event->get_start_date());
                $item->set_auth(CalendarService::get_categories_manager()->get_heritated_authorizations($category->get_id(), Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $result->dispose();
            return $data;
        }
    }
 public function execute(HTTPRequestCustom $request)
 {
     $event_id = $request->get_getint('event_id', 0);
     $current_user_id = AppContext::get_current_user()->get_id();
     if (!empty($event_id)) {
         $this->get_event($event_id);
         $this->check_authorizations();
         if (in_array($current_user_id, array_keys($this->event->get_participants()))) {
             CalendarService::delete_participant($event_id, $current_user_id);
             CalendarCurrentMonthEventsCache::invalidate();
         }
         $category = $this->event->get_content()->get_category();
         AppContext::get_response()->redirect($request->get_url_referrer() ? $request->get_url_referrer() : CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event_id, $this->event->get_content()->get_rewrited_title()));
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 public function get_actions_tree_links()
 {
     $request = AppContext::get_request();
     $year = $request->get_getint('year', date('Y'));
     $month = $request->get_getint('month', date('n'));
     $day = $request->get_getint('day', date('j'));
     $lang = LangLoader::get('common', 'calendar');
     $tree = new ModuleTreeLinks();
     $manage_categories_link = new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), CalendarUrlBuilder::manage_categories());
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('categories.manage', 'categories-common'), CalendarUrlBuilder::manage_categories()));
     $manage_categories_link->add_sub_link(new AdminModuleLink(LangLoader::get_message('category.add', 'categories-common'), CalendarUrlBuilder::add_category()));
     $tree->add_link($manage_categories_link);
     $manage_events_link = new AdminModuleLink($lang['calendar.manage'], CalendarUrlBuilder::manage_events());
     $manage_events_link->add_sub_link(new AdminModuleLink($lang['calendar.manage'], CalendarUrlBuilder::manage_events()));
     $manage_events_link->add_sub_link(new AdminModuleLink($lang['calendar.titles.add_event'], CalendarUrlBuilder::add_event($year, $month, $day)));
     $tree->add_link($manage_events_link);
     $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin-common'), CalendarUrlBuilder::configuration()));
     if (!AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
         $tree->add_link(new ModuleLink($lang['calendar.titles.add_event'], CalendarUrlBuilder::add_event($year, $month, $day), CalendarAuthorizationsService::check_authorizations()->write() || CalendarAuthorizationsService::check_authorizations()->contribution()));
     }
     $tree->add_link(new ModuleLink($lang['calendar.events_list'], CalendarUrlBuilder::events_list($year, $month, $day), CalendarAuthorizationsService::check_authorizations()->read()));
     $tree->add_link(new ModuleLink($lang['calendar.pending'], CalendarUrlBuilder::display_pending_events(), CalendarAuthorizationsService::check_authorizations()->write() || CalendarAuthorizationsService::check_authorizations()->contribution() || CalendarAuthorizationsService::check_authorizations()->moderation()));
     return $tree;
 }
 private function generate_response()
 {
     $event = $this->get_event();
     $response = new SiteDisplayResponse($this->tpl);
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($event->get_content()->get_title(), $this->lang['module_title']);
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], CalendarUrlBuilder::home());
     $category = $event->get_content()->get_category();
     $breadcrumb->add($event->get_content()->get_title(), CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()));
     $graphical_environment->get_seo_meta_data()->set_canonical_url(CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()));
     return $response;
 }
Exemplo n.º 7
0
 public function get_array_tpl_vars()
 {
     $lang = LangLoader::get('common', 'calendar');
     $category = $this->content->get_category();
     $author = $this->content->get_author_user();
     $author_group_color = User::get_group_color($author->get_groups(), $author->get_level(), true);
     $missing_participants_number = $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() < $this->content->get_max_registered_members() ? $this->content->get_max_registered_members() - $this->get_registered_members_number() : 0;
     $registration_days_left = $this->content->get_last_registration_date() && time() < $this->content->get_last_registration_date()->get_timestamp() ? (int) (($this->content->get_last_registration_date()->get_timestamp() - time()) / 3600 / 24) : 0;
     return array('C_APPROVED' => $this->content->is_approved(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_LOCATION' => $this->content->get_location(), 'C_BELONGS_TO_A_SERIE' => $this->belongs_to_a_serie(), 'C_PARTICIPATION_ENABLED' => $this->content->is_registration_authorized(), 'C_DISPLAY_PARTICIPANTS' => $this->content->is_authorized_to_display_registered_users(), 'C_PARTICIPANTS' => !empty($this->participants), 'C_PARTICIPATE' => $this->content->is_registration_authorized() && $this->content->is_authorized_to_register() && time() < $this->start_date->get_timestamp() && (!$this->content->get_max_registered_members() || $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() < $this->content->get_max_registered_members()) && (!$this->content->get_last_registration_date() || $this->content->is_last_registration_date_enabled() && time() < $this->content->get_last_registration_date()->get_timestamp()) && !in_array(AppContext::get_current_user()->get_id(), array_keys($this->participants)), 'C_IS_PARTICIPANT' => in_array(AppContext::get_current_user()->get_id(), array_keys($this->participants)), 'C_REGISTRATION_CLOSED' => $this->content->is_last_registration_date_enabled() && $this->content->get_last_registration_date() && time() > $this->content->get_last_registration_date()->get_timestamp(), 'C_MAX_PARTICIPANTS_REACHED' => $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() == $this->content->get_max_registered_members(), 'C_MISSING_PARTICIPANTS' => !empty($missing_participants_number) && $missing_participants_number <= 5, 'C_REGISTRATION_DAYS_LEFT' => !empty($registration_days_left) && $registration_days_left <= 5, 'C_AUTHOR_GROUP_COLOR' => !empty($author_group_color), 'C_AUTHOR_EXIST' => $author->get_id() !== User::VISITOR_LEVEL, 'ID' => $this->id, 'CONTENT_ID' => $this->content->get_id(), 'TITLE' => $this->content->get_title(), 'CONTENTS' => FormatingHelper::second_parse($this->content->get_contents()), 'LOCATION' => $this->content->get_location(), 'START_DATE' => $this->start_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'START_DATE_DAY' => $this->start_date->get_day(), 'START_DATE_MONTH' => $this->start_date->get_month(), 'START_DATE_YEAR' => $this->start_date->get_year(), 'START_DATE_HOUR' => $this->start_date->get_hours(), 'START_DATE_MINUTE' => $this->start_date->get_minutes(), 'START_DATE_ISO8601' => $this->start_date->format(Date::FORMAT_ISO8601), 'END_DATE' => $this->end_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'END_DATE_DAY' => $this->end_date->get_day(), 'END_DATE_MONTH' => $this->end_date->get_month(), 'END_DATE_YEAR' => $this->end_date->get_year(), 'END_DATE_HOUR' => $this->end_date->get_hours(), 'END_DATE_MINUTE' => $this->end_date->get_minutes(), 'END_DATE_ISO8601' => $this->end_date->format(Date::FORMAT_ISO8601), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('calendar', $this->id), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('calendar', $this->id), 'REPEAT_NUMBER' => $this->content->get_repeat_number(), 'AUTHOR' => $author->get_display_name(), 'AUTHOR_LEVEL_CLASS' => UserService::get_level_class($author->get_level()), 'AUTHOR_GROUP_COLOR' => $author_group_color, 'L_MISSING_PARTICIPANTS' => $missing_participants_number > 1 ? StringVars::replace_vars($lang['calendar.labels.remaining_places'], array('missing_number' => $missing_participants_number)) : $lang['calendar.labels.remaining_place'], 'L_REGISTRATION_DAYS_LEFT' => $registration_days_left > 1 ? StringVars::replace_vars($lang['calendar.labels.remaining_days'], array('days_left' => $registration_days_left)) : $lang['calendar.labels.remaining_day'], 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_COLOR' => $category->get_id() != Category::ROOT_CATEGORY ? $category->get_color() : '', 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? CalendarUrlBuilder::configuration()->rel() : CalendarUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('calendar', $category->get_id())->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($author->get_id())->rel(), 'U_LINK' => CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $this->id, $this->content->get_rewrited_title())->rel(), 'U_EDIT' => CalendarUrlBuilder::edit_event(!$this->parent_id ? $this->id : $this->parent_id)->rel(), 'U_DELETE' => CalendarUrlBuilder::delete_event($this->id)->rel(), 'U_SUSCRIBE' => CalendarUrlBuilder::suscribe_event($this->id)->rel(), 'U_UNSUSCRIBE' => CalendarUrlBuilder::unsuscribe_event($this->id)->rel(), 'U_COMMENTS' => CalendarUrlBuilder::display_event_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->content->get_rewrited_title())->rel());
 }
 protected function get_categories_management_url()
 {
     return CalendarUrlBuilder::manage_categories();
 }
 private function generate_response()
 {
     $page = AppContext::get_request()->get_getint('page', 1);
     $response = new SiteDisplayResponse($this->tpl);
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($this->lang['calendar.pending'], $this->lang['module_title']);
     $graphical_environment->get_seo_meta_data()->set_description($this->lang['calendar.seo.description.pending']);
     $graphical_environment->get_seo_meta_data()->set_canonical_url(CalendarUrlBuilder::display_pending_events($page));
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], CalendarUrlBuilder::home());
     $breadcrumb->add($this->lang['calendar.pending'], CalendarUrlBuilder::display_pending_events($page));
     return $response;
 }
 protected function get_category_url(Category $category)
 {
     return CalendarUrlBuilder::home();
 }
 protected function get_delete_category_url(Category $category)
 {
     return CalendarUrlBuilder::delete_category($category->get_id());
 }
 private function generate_response()
 {
     $response = new SiteDisplayResponse($this->view);
     $graphical_environment = $response->get_graphical_environment();
     $graphical_environment->set_page_title($this->lang['calendar.events_list'], $this->lang['module_title']);
     $breadcrumb = $graphical_environment->get_breadcrumb();
     $breadcrumb->add($this->lang['module_title'], CalendarUrlBuilder::home());
     $breadcrumb->add($this->lang['calendar.events_list'], CalendarUrlBuilder::events_list());
     $graphical_environment->get_seo_meta_data()->set_canonical_url(CalendarUrlBuilder::events_list());
     return $response;
 }
    private function build_view(HTTPRequestCustom $request)
    {
        $config = CalendarConfig::load();
        $categories = CalendarService::get_categories_manager()->get_categories_cache()->get_categories();
        $year = $this->year ? $this->year : min($request->get_int('calendar_ajax_year', date('Y')), 2037);
        $month = $this->month ? $this->month : min($request->get_int('calendar_ajax_month', date('n')), 12);
        $bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28;
        $array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
        $array_l_month = array($this->lang['january'], $this->lang['february'], $this->lang['march'], $this->lang['april'], $this->lang['may'], $this->lang['june'], $this->lang['july'], $this->lang['august'], $this->lang['september'], $this->lang['october'], $this->lang['november'], $this->lang['december']);
        $month_days = $array_month[$month - 1];
        $previous_month = $month == 1 ? 12 : $month - 1;
        $previous_year = $month == 1 ? $year - 1 : $year;
        $next_month = $month == 12 ? 1 : $month + 1;
        $next_year = $month == 12 ? $year + 1 : $year;
        //Months
        for ($i = 1; $i <= 12; $i++) {
            $this->view->assign_block_vars('months', array('VALUE' => $i, 'NAME' => $array_l_month[$i - 1], 'SELECTED' => $month == $i));
        }
        //Years
        for ($i = 1970; $i <= 2037; $i++) {
            $this->view->assign_block_vars('years', array('VALUE' => $i, 'NAME' => $i, 'SELECTED' => $year == $i));
        }
        //Retrieve all the events of the selected month
        $events = $month == date('n') && $year == date('Y') ? CalendarCurrentMonthEventsCache::load()->get_events() : CalendarService::get_all_current_month_events($month, $year, $month_days);
        $events_legends_list = array();
        foreach ($events as $event) {
            $start_date = new Date($event['start_date'], Timezone::SERVER_TIMEZONE);
            $end_date = new Date($event['end_date'], Timezone::SERVER_TIMEZONE);
            if (($end_date->get_month() > $start_date->get_month() || $end_date->get_year() > $start_date->get_year()) && $month == $start_date->get_month()) {
                $first_event_day = $start_date->get_day();
                $last_event_day = $array_month[$month - 1];
            } else {
                if (($end_date->get_month() > $start_date->get_month() || $end_date->get_year() > $start_date->get_year()) && $month == $end_date->get_month()) {
                    $first_event_day = 1;
                    $last_event_day = $end_date->get_day();
                } else {
                    if (($end_date->get_month() > $start_date->get_month() || $end_date->get_year() > $start_date->get_year()) && $month > $start_date->get_month() && $month < $end_date->get_month()) {
                        $first_event_day = 1;
                        $last_event_day = $array_month[$month - 1];
                    } else {
                        $first_event_day = $start_date->get_day();
                        $last_event_day = $end_date->get_day();
                    }
                }
            }
            for ($j = $first_event_day; $j <= $last_event_day; $j++) {
                if ($event['type'] == 'EVENT' || $event['type'] == 'BIRTHDAY') {
                    $title = isset($array_events[$j]['title']) ? $array_events[$j]['title'] : '';
                    $array_events[$j] = array('title' => $title . (!empty($title) ? '
' : '') . ($event['type'] != 'BIRTHDAY' ? $j == $start_date->get_day() && $month == $start_date->get_month() && $year == $start_date->get_year() ? $start_date->get_hours() . 'h' . $start_date->get_minutes() . ' : ' : '' : LangLoader::get_message('calendar.labels.birthday_title', 'common', 'calendar') . ' ') . $event['title'], 'type' => $event['type'], 'color' => $event['type'] == 'BIRTHDAY' ? $config->get_birthday_color() : ($event['id_category'] != Category::ROOT_CATEGORY && $categories[$event['id_category']]->get_color() ? $categories[$event['id_category']]->get_color() : $config->get_event_color()), 'id_category' => $event['id_category']);
                    if ($event['type'] == 'BIRTHDAY') {
                        $events_legends_list[$j] = array('name' => LangLoader::get_message('calendar.labels.birthday', 'common', 'calendar'), 'color' => $config->get_birthday_color());
                    } else {
                        if ($event['type'] == 'EVENT' && $event['id_category'] == Category::ROOT_CATEGORY) {
                            $events_legends_list[$j] = array('name' => LangLoader::get_message('calendar.titles.event', 'common', 'calendar'), 'color' => $config->get_event_color());
                        } else {
                            if (!isset($events_legends_list[$event['id_category']])) {
                                $events_legends_list[$j] = array('name' => $categories[$event['id_category']]->get_name(), 'color' => $categories[$event['id_category']]->get_color());
                            }
                        }
                    }
                }
            }
        }
        $this->view->put_all(array('C_MINI_MODULE' => $this->is_mini_calendar(), 'C_DISPLAY_LEGEND' => !empty($events_legends_list) && !$this->is_mini_calendar(), 'DATE' => $array_l_month[$month - 1] . ' ' . $year, 'MINI_MODULE' => (int) $this->is_mini_calendar(), 'PREVIOUS_MONTH_TITLE' => $month == 1 ? $array_l_month[11] . ' ' . ($year - 1) : $array_l_month[$month - 2] . ' ' . $year, 'PREVIOUS_YEAR' => $previous_year, 'PREVIOUS_MONTH' => $previous_month, 'NEXT_MONTH_TITLE' => $month == 12 ? $array_l_month[0] . ' ' . ($year + 1) : $array_l_month[$month] . ' ' . $year, 'NEXT_YEAR' => $next_year, 'NEXT_MONTH' => $next_month, 'LEGEND' => self::build_legend($events_legends_list), 'U_AJAX_CALENDAR' => CalendarUrlBuilder::ajax_month_calendar()->rel(), 'U_AJAX_EVENTS' => CalendarUrlBuilder::ajax_month_events()->rel()));
        //First day of the month
        $first_day = date('w', @mktime(1, 0, 0, $month, 1, $year));
        if ($first_day == 0) {
            $first_day = 7;
        }
        //Calendar generation
        $day = 1;
        $last_day = $month_days + $first_day;
        for ($i = 1; $i <= 56; $i++) {
            $birthday_day = $color = false;
            if ($i % 8 == 1 && $i < $last_day) {
                $content = date('W', mktime(0, 0, 0, $month, $day, $year));
                $class = 'calendar-week';
                $last_day++;
            } else {
                if ($i >= $first_day + 1 && $i < $last_day) {
                    if ($day == date("j") && $month == date("m") && $year == date("Y")) {
                        $class = 'calendar-today';
                    } else {
                        if (!empty($array_events[$day])) {
                            $birthday_day = $array_events[$day]['type'] == 'BIRTHDAY';
                            $color = $array_events[$day]['color'];
                            $class = '';
                        } else {
                            if ($i % 8 == 7 || $i % 8 == 0) {
                                $class = 'calendar-weekend';
                            } else {
                                $class = 'calendar-other';
                            }
                        }
                    }
                    $content = $day;
                    $day++;
                } else {
                    if (($i % 8 == 7 || $i % 8 == 0) && $i > $first_day && $day <= $month_days) {
                        $class = 'calendar-weekend';
                    } else {
                        $class = 'calendar-none';
                    }
                }
            }
            if ($day > $month_days && $i % 8 == 0) {
                $i = 56;
            }
            $today = $day - 1;
            $this->view->assign_block_vars('day', array('C_MONTH_DAY' => $i % 8 != 1 && $class != 'calendar-none', 'C_COLOR' => $color || $birthday_day, 'C_WEEK_LABEL' => $i % 8 == 1, 'DAY' => $content, 'TITLE' => !empty($array_events[$today]) ? $array_events[$today]['title'] : '', 'COLOR' => $color, 'CLASS' => $class, 'CHANGE_LINE' => $i % 8 == 0 && $i != 56, 'U_DAY_EVENTS' => CalendarUrlBuilder::home($year, $month, $today, true)->rel()));
        }
    }